diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/stats/TransportClusterStatsAction.java b/src/main/java/org/elasticsearch/action/admin/cluster/stats/TransportClusterStatsAction.java index 9cb038b3623..edf0e54e4c5 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/stats/TransportClusterStatsAction.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/stats/TransportClusterStatsAction.java @@ -37,8 +37,8 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.node.service.NodeService; import org.elasticsearch.threadpool.ThreadPool; diff --git a/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java b/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java index 88fefafd57d..405d79cbd0d 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java @@ -42,7 +42,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.analysis.*; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.internal.AllFieldMapper; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.analysis.IndicesAnalysisService; diff --git a/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java b/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java index d162f758b53..cf257401b19 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/cache/clear/TransportClearIndicesCacheAction.java @@ -34,8 +34,8 @@ import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.mapper.internal.ParentFieldMapper; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.cache.filter.terms.IndicesTermsFilterCache; import org.elasticsearch.indices.cache.query.IndicesQueryCache; diff --git a/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java b/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java index 83c1919340c..5cbfcda0a10 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/flush/TransportFlushAction.java @@ -33,8 +33,7 @@ import org.elasticsearch.cluster.routing.GroupShardsIterator; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.engine.Engine; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; diff --git a/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java b/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java index 4771d4879ee..25e29bca714 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetFieldMappingsIndexAction.java @@ -40,7 +40,7 @@ import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.mapper.DocumentFieldMappers; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.FieldMapper; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.TypeMissingException; diff --git a/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java b/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java index b5c48e9595f..a6cb0b15eff 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/optimize/TransportOptimizeAction.java @@ -33,7 +33,7 @@ import org.elasticsearch.cluster.routing.GroupShardsIterator; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; diff --git a/src/main/java/org/elasticsearch/action/admin/indices/recovery/TransportRecoveryAction.java b/src/main/java/org/elasticsearch/action/admin/indices/recovery/TransportRecoveryAction.java index 0bd5e946ce7..1e9759d8b07 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/recovery/TransportRecoveryAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/recovery/TransportRecoveryAction.java @@ -35,9 +35,9 @@ import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.gateway.IndexShardGatewayService; -import org.elasticsearch.index.service.InternalIndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.recovery.RecoveryState; import org.elasticsearch.indices.recovery.RecoveryTarget; @@ -141,8 +141,8 @@ public class TransportRecoveryAction extends @Override protected ShardRecoveryResponse shardOperation(ShardRecoveryRequest request) throws ElasticsearchException { - InternalIndexService indexService = (InternalIndexService) indicesService.indexServiceSafe(request.shardId().getIndex()); - InternalIndexShard indexShard = (InternalIndexShard) indexService.shardSafe(request.shardId().id()); + IndexService indexService = indicesService.indexServiceSafe(request.shardId().getIndex()); + IndexShard indexShard = indexService.shardSafe(request.shardId().id()); ShardRecoveryResponse shardRecoveryResponse = new ShardRecoveryResponse(request.shardId()); RecoveryState state = indexShard.recoveryState(); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java b/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java index b8bf8905562..88f89706b89 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java @@ -33,8 +33,7 @@ import org.elasticsearch.cluster.routing.GroupShardsIterator; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.engine.Engine; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; diff --git a/src/main/java/org/elasticsearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java b/src/main/java/org/elasticsearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java index 492ff58db46..a634ea3f208 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java @@ -34,9 +34,9 @@ import org.elasticsearch.cluster.routing.GroupShardsIterator; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.service.InternalIndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; @@ -129,8 +129,8 @@ public class TransportIndicesSegmentsAction extends TransportBroadcastOperationA @Override protected ShardSegments shardOperation(IndexShardSegmentRequest request) throws ElasticsearchException { - InternalIndexService indexService = (InternalIndexService) indicesService.indexServiceSafe(request.shardId().getIndex()); - InternalIndexShard indexShard = (InternalIndexShard) indexService.shardSafe(request.shardId().id()); + IndexService indexService = indicesService.indexServiceSafe(request.shardId().getIndex()); + IndexShard indexShard = indexService.shardSafe(request.shardId().id()); return new ShardSegments(indexShard.routingEntry(), indexShard.engine().segments()); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStats.java b/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStats.java index b3cc53245c0..fe1addd332b 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStats.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/stats/CommonStats.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.indices.stats; -import org.elasticsearch.Version; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -40,7 +39,7 @@ import org.elasticsearch.index.percolator.stats.PercolateStats; import org.elasticsearch.index.refresh.RefreshStats; import org.elasticsearch.index.search.stats.SearchStats; import org.elasticsearch.index.shard.DocsStats; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.store.StoreStats; import org.elasticsearch.index.suggest.stats.SuggestStats; import org.elasticsearch.index.translog.TranslogStats; diff --git a/src/main/java/org/elasticsearch/action/admin/indices/stats/ShardStats.java b/src/main/java/org/elasticsearch/action/admin/indices/stats/ShardStats.java index 73618125bc4..0a118d3154b 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/stats/ShardStats.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/stats/ShardStats.java @@ -26,7 +26,7 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilderString; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import java.io.IOException; diff --git a/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java b/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java index eb6dd735df1..c7fde2f517e 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java @@ -38,9 +38,9 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexShardMissingException; -import org.elasticsearch.index.service.InternalIndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; @@ -134,8 +134,8 @@ public class TransportIndicesStatsAction extends TransportBroadcastOperationActi @Override protected ShardStats shardOperation(IndexShardStatsRequest request) throws ElasticsearchException { - InternalIndexService indexService = (InternalIndexService) indicesService.indexServiceSafe(request.shardId().getIndex()); - InternalIndexShard indexShard = (InternalIndexShard) indexService.shardSafe(request.shardId().id()); + IndexService indexService = indicesService.indexServiceSafe(request.shardId().getIndex()); + IndexShard indexShard = indexService.shardSafe(request.shardId().id()); // if we don't have the routing entry yet, we need it stats wise, we treat it as if the shard is not ready yet if (indexShard.routingEntry() == null) { throw new IndexShardMissingException(indexShard.shardId()); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java index 7f9764fcc2f..ee39fa68c4e 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/TransportValidateQueryAction.java @@ -38,8 +38,8 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.index.query.IndexQueryParserService; import org.elasticsearch.index.query.QueryParsingException; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.search.internal.DefaultSearchContext; diff --git a/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java b/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java index 8c2e305abec..7aad2200042 100644 --- a/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java +++ b/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java @@ -54,8 +54,8 @@ import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.engine.VersionConflictEngineException; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.SourceToParse; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.threadpool.ThreadPool; diff --git a/src/main/java/org/elasticsearch/action/count/TransportCountAction.java b/src/main/java/org/elasticsearch/action/count/TransportCountAction.java index cfed32995a0..80247c6c4a9 100644 --- a/src/main/java/org/elasticsearch/action/count/TransportCountAction.java +++ b/src/main/java/org/elasticsearch/action/count/TransportCountAction.java @@ -39,8 +39,8 @@ import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.index.query.QueryParseContext; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.search.SearchShardTarget; diff --git a/src/main/java/org/elasticsearch/action/delete/TransportDeleteAction.java b/src/main/java/org/elasticsearch/action/delete/TransportDeleteAction.java index b4a661d3966..ab913edf12f 100644 --- a/src/main/java/org/elasticsearch/action/delete/TransportDeleteAction.java +++ b/src/main/java/org/elasticsearch/action/delete/TransportDeleteAction.java @@ -38,7 +38,7 @@ import org.elasticsearch.common.lucene.uid.Versions; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.VersionType; import org.elasticsearch.index.engine.Engine; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndexAlreadyExistsException; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; diff --git a/src/main/java/org/elasticsearch/action/delete/TransportShardDeleteAction.java b/src/main/java/org/elasticsearch/action/delete/TransportShardDeleteAction.java index a0a8ab31c5a..631a618a614 100644 --- a/src/main/java/org/elasticsearch/action/delete/TransportShardDeleteAction.java +++ b/src/main/java/org/elasticsearch/action/delete/TransportShardDeleteAction.java @@ -31,7 +31,7 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.VersionType; import org.elasticsearch.index.engine.Engine; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; diff --git a/src/main/java/org/elasticsearch/action/deletebyquery/TransportShardDeleteByQueryAction.java b/src/main/java/org/elasticsearch/action/deletebyquery/TransportShardDeleteByQueryAction.java index 909c9fd0512..24bf5cc9a5f 100644 --- a/src/main/java/org/elasticsearch/action/deletebyquery/TransportShardDeleteByQueryAction.java +++ b/src/main/java/org/elasticsearch/action/deletebyquery/TransportShardDeleteByQueryAction.java @@ -35,8 +35,8 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.query.ParsedQuery; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.search.internal.DefaultSearchContext; @@ -128,7 +128,7 @@ public class TransportShardDeleteByQueryAction extends TransportShardReplication IndexShard indexShard = indexService.shardSafe(shardRequest.shardId.id()); SearchContext.setCurrent(new DefaultSearchContext(0, new ShardSearchLocalRequest(request.types(), request.nowInMillis()), null, - indexShard.acquireSearcher(DELETE_BY_QUERY_API, IndexShard.Mode.WRITE), indexService, indexShard, scriptService, + indexShard.acquireSearcher(DELETE_BY_QUERY_API, true), indexService, indexShard, scriptService, pageCacheRecycler, bigArrays, threadPool.estimatedTimeInMillisCounter())); try { Engine.DeleteByQuery deleteByQuery = indexShard.prepareDeleteByQuery(request.source(), request.filteringAliases(), Engine.Operation.Origin.REPLICA, request.types()); diff --git a/src/main/java/org/elasticsearch/action/exists/TransportExistsAction.java b/src/main/java/org/elasticsearch/action/exists/TransportExistsAction.java index fd68d69282f..d111ee07b09 100644 --- a/src/main/java/org/elasticsearch/action/exists/TransportExistsAction.java +++ b/src/main/java/org/elasticsearch/action/exists/TransportExistsAction.java @@ -41,8 +41,8 @@ import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.index.query.QueryParseContext; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.search.SearchShardTarget; diff --git a/src/main/java/org/elasticsearch/action/explain/TransportExplainAction.java b/src/main/java/org/elasticsearch/action/explain/TransportExplainAction.java index 1dacfb24dcd..81f077ebe19 100644 --- a/src/main/java/org/elasticsearch/action/explain/TransportExplainAction.java +++ b/src/main/java/org/elasticsearch/action/explain/TransportExplainAction.java @@ -37,9 +37,9 @@ import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.get.GetResult; import org.elasticsearch.index.mapper.Uid; import org.elasticsearch.index.mapper.internal.UidFieldMapper; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.search.internal.DefaultSearchContext; diff --git a/src/main/java/org/elasticsearch/action/get/TransportGetAction.java b/src/main/java/org/elasticsearch/action/get/TransportGetAction.java index 561ad705f8e..eed7881e59d 100644 --- a/src/main/java/org/elasticsearch/action/get/TransportGetAction.java +++ b/src/main/java/org/elasticsearch/action/get/TransportGetAction.java @@ -28,11 +28,10 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.routing.ShardIterator; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.get.GetResult; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; diff --git a/src/main/java/org/elasticsearch/action/get/TransportShardMultiGetAction.java b/src/main/java/org/elasticsearch/action/get/TransportShardMultiGetAction.java index 1e45fd6430c..ec2d73cf26e 100644 --- a/src/main/java/org/elasticsearch/action/get/TransportShardMultiGetAction.java +++ b/src/main/java/org/elasticsearch/action/get/TransportShardMultiGetAction.java @@ -29,11 +29,10 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.routing.ShardIterator; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.get.GetResult; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; diff --git a/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java b/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java index 1831f031908..50e53b906d7 100644 --- a/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java +++ b/src/main/java/org/elasticsearch/action/index/TransportIndexAction.java @@ -40,8 +40,8 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.mapper.SourceToParse; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndexAlreadyExistsException; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; diff --git a/src/main/java/org/elasticsearch/action/suggest/TransportSuggestAction.java b/src/main/java/org/elasticsearch/action/suggest/TransportSuggestAction.java index a151e469632..fb139670aa3 100644 --- a/src/main/java/org/elasticsearch/action/suggest/TransportSuggestAction.java +++ b/src/main/java/org/elasticsearch/action/suggest/TransportSuggestAction.java @@ -38,8 +38,8 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.engine.Engine; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.suggest.stats.ShardSuggestService; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.search.suggest.Suggest; diff --git a/src/main/java/org/elasticsearch/action/support/replication/TransportShardReplicationOperationAction.java b/src/main/java/org/elasticsearch/action/support/replication/TransportShardReplicationOperationAction.java index aeb256db0f7..0c1480c9985 100644 --- a/src/main/java/org/elasticsearch/action/support/replication/TransportShardReplicationOperationAction.java +++ b/src/main/java/org/elasticsearch/action/support/replication/TransportShardReplicationOperationAction.java @@ -41,9 +41,9 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.AbstractRunnable; import org.elasticsearch.index.engine.DocumentAlreadyExistsException; import org.elasticsearch.index.engine.VersionConflictEngineException; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.node.NodeClosedException; import org.elasticsearch.rest.RestStatus; diff --git a/src/main/java/org/elasticsearch/action/termvectors/TransportShardMultiTermsVectorAction.java b/src/main/java/org/elasticsearch/action/termvectors/TransportShardMultiTermsVectorAction.java index fb679d128d2..ff9b49a04be 100644 --- a/src/main/java/org/elasticsearch/action/termvectors/TransportShardMultiTermsVectorAction.java +++ b/src/main/java/org/elasticsearch/action/termvectors/TransportShardMultiTermsVectorAction.java @@ -29,9 +29,9 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.routing.ShardIterator; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; diff --git a/src/main/java/org/elasticsearch/action/termvectors/TransportTermVectorsAction.java b/src/main/java/org/elasticsearch/action/termvectors/TransportTermVectorsAction.java index 1c2317d9824..be7264c3131 100644 --- a/src/main/java/org/elasticsearch/action/termvectors/TransportTermVectorsAction.java +++ b/src/main/java/org/elasticsearch/action/termvectors/TransportTermVectorsAction.java @@ -28,9 +28,9 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.routing.ShardIterator; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; diff --git a/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java b/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java index b18b5d868be..687c789b7df 100644 --- a/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java +++ b/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java @@ -52,8 +52,8 @@ import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.engine.DocumentAlreadyExistsException; import org.elasticsearch.index.engine.VersionConflictEngineException; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndexAlreadyExistsException; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; diff --git a/src/main/java/org/elasticsearch/action/update/UpdateHelper.java b/src/main/java/org/elasticsearch/action/update/UpdateHelper.java index 708b249b71e..091bd2bb475 100644 --- a/src/main/java/org/elasticsearch/action/update/UpdateHelper.java +++ b/src/main/java/org/elasticsearch/action/update/UpdateHelper.java @@ -42,9 +42,8 @@ import org.elasticsearch.index.mapper.internal.ParentFieldMapper; import org.elasticsearch.index.mapper.internal.RoutingFieldMapper; import org.elasticsearch.index.mapper.internal.TTLFieldMapper; import org.elasticsearch.index.mapper.internal.TimestampFieldMapper; -import org.elasticsearch.index.service.IndexService; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.script.ExecutableScript; import org.elasticsearch.script.ScriptService; import org.elasticsearch.search.fetch.source.FetchSourceContext; diff --git a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java index 7d2187c714f..cc89db535fa 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java @@ -62,7 +62,7 @@ import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.query.IndexQueryParserService; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.indices.IndexAlreadyExistsException; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.InvalidIndexNameException; @@ -72,7 +72,6 @@ import org.elasticsearch.threadpool.ThreadPool; import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.nio.file.DirectoryStream; import java.nio.file.Files; diff --git a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesService.java b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesService.java index fe660f9083b..e8b301597a0 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesService.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexAliasesService.java @@ -35,7 +35,7 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; import org.elasticsearch.index.mapper.MapperService; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.indices.IndexMissingException; import org.elasticsearch.indices.IndicesService; diff --git a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataMappingService.java b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataMappingService.java index 1c702fbd065..8c5297424a6 100644 --- a/src/main/java/org/elasticsearch/cluster/metadata/MetaDataMappingService.java +++ b/src/main/java/org/elasticsearch/cluster/metadata/MetaDataMappingService.java @@ -40,7 +40,7 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.MergeMappingException; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.indices.IndexMissingException; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.InvalidTypeNameException; diff --git a/src/main/java/org/elasticsearch/index/IndexModule.java b/src/main/java/org/elasticsearch/index/IndexModule.java index 030a38a86ce..d94eb4f9c7d 100644 --- a/src/main/java/org/elasticsearch/index/IndexModule.java +++ b/src/main/java/org/elasticsearch/index/IndexModule.java @@ -21,8 +21,6 @@ package org.elasticsearch.index; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.service.InternalIndexService; /** * @@ -37,6 +35,6 @@ public class IndexModule extends AbstractModule { @Override protected void configure() { - bind(IndexService.class).to(InternalIndexService.class).asEagerSingleton(); + bind(IndexService.class).asEagerSingleton(); } } diff --git a/src/main/java/org/elasticsearch/index/service/InternalIndexService.java b/src/main/java/org/elasticsearch/index/IndexService.java similarity index 93% rename from src/main/java/org/elasticsearch/index/service/InternalIndexService.java rename to src/main/java/org/elasticsearch/index/IndexService.java index f533eca7ef9..d0471a34d1e 100644 --- a/src/main/java/org/elasticsearch/index/service/InternalIndexService.java +++ b/src/main/java/org/elasticsearch/index/IndexService.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.service; +package org.elasticsearch.index; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; @@ -65,8 +65,7 @@ import org.elasticsearch.index.settings.IndexSettingsService; import org.elasticsearch.index.shard.IndexShardCreationException; import org.elasticsearch.index.shard.IndexShardModule; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; -import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.similarity.SimilarityService; import org.elasticsearch.index.snapshots.IndexShardSnapshotModule; import org.elasticsearch.index.store.IndexStore; @@ -98,7 +97,7 @@ import static org.elasticsearch.common.collect.MapBuilder.newMapBuilder; /** * */ -public class InternalIndexService extends AbstractIndexComponent implements IndexService { +public class IndexService extends AbstractIndexComponent implements IndexComponent, Iterable { private final Injector injector; @@ -141,11 +140,11 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde private final AtomicBoolean closed = new AtomicBoolean(false); @Inject - public InternalIndexService(Injector injector, Index index, @IndexSettings Settings indexSettings, NodeEnvironment nodeEnv, - AnalysisService analysisService, MapperService mapperService, IndexQueryParserService queryParserService, - SimilarityService similarityService, IndexAliasesService aliasesService, IndexCache indexCache, IndexEngine indexEngine, - IndexGateway indexGateway, IndexStore indexStore, IndexSettingsService settingsService, IndexFieldDataService indexFieldData, - BitsetFilterCache bitSetFilterCache ) { + public IndexService(Injector injector, Index index, @IndexSettings Settings indexSettings, NodeEnvironment nodeEnv, + AnalysisService analysisService, MapperService mapperService, IndexQueryParserService queryParserService, + SimilarityService similarityService, IndexAliasesService aliasesService, IndexCache indexCache, IndexEngine indexEngine, + IndexGateway indexGateway, IndexStore indexStore, IndexSettingsService settingsService, IndexFieldDataService indexFieldData, + BitsetFilterCache bitSetFilterCache) { super(index, indexSettings); this.injector = injector; this.indexSettings = indexSettings; @@ -172,7 +171,6 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde this.nodeEnv = nodeEnv; } - @Override public int numberOfShards() { return shards.size(); } @@ -182,17 +180,20 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde return shards.values().iterator(); } - @Override public boolean hasShard(int shardId) { return shards.containsKey(shardId); } - @Override + /** + * Return the shard with the provided id, or null if there is no such shard. + */ + @Nullable public IndexShard shard(int shardId) { return shards.get(shardId); } - - @Override + /** + * Return the shard with the provided id, or throw an exception if it doesn't exist. + */ public IndexShard shardSafe(int shardId) throws IndexShardMissingException { IndexShard indexShard = shard(shardId); if (indexShard == null) { @@ -201,72 +202,58 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde return indexShard; } - @Override public ImmutableSet shardIds() { return shards.keySet(); } - @Override public Injector injector() { return injector; } - @Override public IndexGateway gateway() { return indexGateway; } - @Override public IndexSettingsService settingsService() { return this.settingsService; } - @Override public IndexStore store() { return indexStore; } - @Override public IndexCache cache() { return indexCache; } - @Override public IndexFieldDataService fieldData() { return indexFieldData; } - @Override public BitsetFilterCache bitsetFilterCache() { return bitsetFilterCache; } - @Override public AnalysisService analysisService() { return this.analysisService; } - @Override public MapperService mapperService() { return mapperService; } - @Override public IndexQueryParserService queryParserService() { return queryParserService; } - @Override public SimilarityService similarityService() { return similarityService; } - @Override public IndexAliasesService aliasesService() { return aliasesService; } - @Override public IndexEngine engine() { return indexEngine; } @@ -286,12 +273,17 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde } } - @Override + /** + * Return the shard injector for the provided id, or null if there is no such shard. + */ + @Nullable public Injector shardInjector(int shardId) throws ElasticsearchException { return shardsInjectors.get(shardId); } - @Override + /** + * Return the shard injector for the provided id, or throw an exception if there is no such shard. + */ public Injector shardInjectorSafe(int shardId) throws IndexShardMissingException { Injector shardInjector = shardInjector(shardId); if (shardInjector == null) { @@ -300,12 +292,10 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde return shardInjector; } - @Override public String indexUUID() { return indexSettings.get(IndexMetaData.SETTING_UUID, IndexMetaData.INDEX_UUID_NA_VALUE); } - @Override public synchronized IndexShard createShard(int sShardId) throws ElasticsearchException { /* * TODO: we execute this in parallel but it's a synced method. Yet, we might @@ -330,7 +320,7 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde ModulesBuilder modules = new ModulesBuilder(); modules.add(new ShardsPluginsModule(indexSettings, pluginsService)); - modules.add(new IndexShardModule(indexSettings, shardId)); + modules.add(new IndexShardModule(shardId)); modules.add(new ShardIndexingModule()); modules.add(new ShardSearchModule()); modules.add(new ShardGetModule()); @@ -377,7 +367,6 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde } } - @Override public void removeShard(int shardId, String reason) throws ElasticsearchException { removeShard(shardId, reason, null); } @@ -418,7 +407,7 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde // and close the shard so no operations are allowed to it if (indexShard != null) { try { - ((InternalIndexShard) indexShard).close(reason); + ((IndexShard) indexShard).close(reason); } catch (Throwable e) { logger.debug("[{}] failed to close index shard", e, shardId); // ignore diff --git a/src/main/java/org/elasticsearch/index/cache/bitset/BitsetFilterCache.java b/src/main/java/org/elasticsearch/index/cache/bitset/BitsetFilterCache.java index 9040bbc8370..bf253d6597b 100644 --- a/src/main/java/org/elasticsearch/index/cache/bitset/BitsetFilterCache.java +++ b/src/main/java/org/elasticsearch/index/cache/bitset/BitsetFilterCache.java @@ -44,12 +44,11 @@ import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.object.ObjectMapper; import org.elasticsearch.index.search.nested.NonNestedDocsFilter; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.service.InternalIndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.ShardUtils; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.warmer.IndicesWarmer; import org.elasticsearch.threadpool.ThreadPool; @@ -93,7 +92,7 @@ public class BitsetFilterCache extends AbstractIndexComponent implements LeafRea this.indicesWarmer = indicesWarmer; } - public void setIndexService(InternalIndexService indexService) { + public void setIndexService(IndexService indexService) { this.indexService = indexService; // First the indicesWarmer is set and then the indexService is set, because of this there is a small window of // time where indexService is null. This is why the warmer should only registered after indexService has been set. diff --git a/src/main/java/org/elasticsearch/index/cache/filter/FilterCache.java b/src/main/java/org/elasticsearch/index/cache/filter/FilterCache.java index d1c8ecc8398..0f883cc909c 100644 --- a/src/main/java/org/elasticsearch/index/cache/filter/FilterCache.java +++ b/src/main/java/org/elasticsearch/index/cache/filter/FilterCache.java @@ -22,7 +22,7 @@ package org.elasticsearch.index.cache.filter; import org.apache.lucene.search.Filter; import org.elasticsearch.common.component.CloseableComponent; import org.elasticsearch.index.IndexComponent; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; /** * diff --git a/src/main/java/org/elasticsearch/index/cache/filter/none/NoneFilterCache.java b/src/main/java/org/elasticsearch/index/cache/filter/none/NoneFilterCache.java index f66e7d3cd2b..99473ae3b3c 100644 --- a/src/main/java/org/elasticsearch/index/cache/filter/none/NoneFilterCache.java +++ b/src/main/java/org/elasticsearch/index/cache/filter/none/NoneFilterCache.java @@ -25,7 +25,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.AbstractIndexComponent; import org.elasticsearch.index.Index; import org.elasticsearch.index.cache.filter.FilterCache; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.settings.IndexSettings; /** diff --git a/src/main/java/org/elasticsearch/index/cache/filter/weighted/WeightedFilterCache.java b/src/main/java/org/elasticsearch/index/cache/filter/weighted/WeightedFilterCache.java index a7b8fd5ff42..23f00f14b1e 100644 --- a/src/main/java/org/elasticsearch/index/cache/filter/weighted/WeightedFilterCache.java +++ b/src/main/java/org/elasticsearch/index/cache/filter/weighted/WeightedFilterCache.java @@ -43,11 +43,11 @@ import org.elasticsearch.index.AbstractIndexComponent; import org.elasticsearch.index.Index; import org.elasticsearch.index.cache.filter.FilterCache; import org.elasticsearch.index.cache.filter.support.CacheKeyFilter; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.ShardUtils; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.cache.filter.IndicesFilterCache; import java.io.IOException; diff --git a/src/main/java/org/elasticsearch/index/fielddata/IndexFieldDataService.java b/src/main/java/org/elasticsearch/index/fielddata/IndexFieldDataService.java index 21f8e23ee7c..39fe7189936 100644 --- a/src/main/java/org/elasticsearch/index/fielddata/IndexFieldDataService.java +++ b/src/main/java/org/elasticsearch/index/fielddata/IndexFieldDataService.java @@ -35,7 +35,7 @@ import org.elasticsearch.index.fielddata.plain.*; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.internal.IndexFieldMapper; import org.elasticsearch.index.mapper.internal.ParentFieldMapper; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache; diff --git a/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayService.java b/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayService.java index 022915d38c8..a33810d1249 100644 --- a/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayService.java +++ b/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayService.java @@ -24,11 +24,9 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.shard.*; -import org.elasticsearch.index.shard.service.IndexShard; -import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.snapshots.IndexShardSnapshotAndRestoreService; import org.elasticsearch.indices.recovery.RecoveryState; import org.elasticsearch.threadpool.ThreadPool; @@ -47,7 +45,7 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem private final ClusterService clusterService; - private final InternalIndexShard indexShard; + private final IndexShard indexShard; private final IndexShardGateway shardGateway; @@ -60,7 +58,7 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem IndexShard indexShard, IndexShardGateway shardGateway, IndexShardSnapshotAndRestoreService snapshotService, ClusterService clusterService) { super(shardId, indexSettings); this.threadPool = threadPool; - this.indexShard = (InternalIndexShard) indexShard; + this.indexShard = indexShard; this.shardGateway = shardGateway; this.snapshotService = snapshotService; this.recoveryState = new RecoveryState(shardId); diff --git a/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexShardGateway.java b/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexShardGateway.java index 41a3401bfdc..2597446e681 100644 --- a/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexShardGateway.java +++ b/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexShardGateway.java @@ -36,25 +36,21 @@ import org.elasticsearch.common.util.concurrent.FutureUtils; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.gateway.IndexShardGateway; import org.elasticsearch.index.gateway.IndexShardGatewayRecoveryException; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.shard.AbstractIndexShardComponent; import org.elasticsearch.index.shard.IndexShardState; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; -import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.translog.*; -import org.elasticsearch.index.translog.fs.FsTranslog; import org.elasticsearch.indices.recovery.RecoveryState; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.threadpool.ThreadPool; import java.io.EOFException; -import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.util.Arrays; import java.util.Set; @@ -72,7 +68,7 @@ public class LocalIndexShardGateway extends AbstractIndexShardComponent implemen private final ThreadPool threadPool; private final MappingUpdatedAction mappingUpdatedAction; private final IndexService indexService; - private final InternalIndexShard indexShard; + private final IndexShard indexShard; private final TimeValue waitForMappingUpdatePostRecovery; @@ -88,7 +84,7 @@ public class LocalIndexShardGateway extends AbstractIndexShardComponent implemen this.threadPool = threadPool; this.mappingUpdatedAction = mappingUpdatedAction; this.indexService = indexService; - this.indexShard = (InternalIndexShard) indexShard; + this.indexShard = indexShard; this.waitForMappingUpdatePostRecovery = componentSettings.getAsTime("wait_for_mapping_update_post_recovery", TimeValue.timeValueSeconds(30)); syncInterval = componentSettings.getAsTime("sync", TimeValue.timeValueSeconds(5)); diff --git a/src/main/java/org/elasticsearch/index/get/ShardGetService.java b/src/main/java/org/elasticsearch/index/get/ShardGetService.java index 1f7568a0d83..22cb6df2752 100644 --- a/src/main/java/org/elasticsearch/index/get/ShardGetService.java +++ b/src/main/java/org/elasticsearch/index/get/ShardGetService.java @@ -47,7 +47,7 @@ import org.elasticsearch.index.mapper.internal.*; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.shard.AbstractIndexShardComponent; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.translog.Translog; import org.elasticsearch.script.ScriptService; import org.elasticsearch.search.fetch.source.FetchSourceContext; diff --git a/src/main/java/org/elasticsearch/index/percolator/PercolatorQueriesRegistry.java b/src/main/java/org/elasticsearch/index/percolator/PercolatorQueriesRegistry.java index f30d38c80b4..c04a706f2ce 100644 --- a/src/main/java/org/elasticsearch/index/percolator/PercolatorQueriesRegistry.java +++ b/src/main/java/org/elasticsearch/index/percolator/PercolatorQueriesRegistry.java @@ -50,7 +50,7 @@ import org.elasticsearch.index.query.QueryParsingException; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.shard.AbstractIndexShardComponent; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesLifecycle; import org.elasticsearch.percolator.PercolatorService; @@ -267,7 +267,7 @@ public class PercolatorQueriesRegistry extends AbstractIndexShardComponent { private int loadQueries(IndexShard shard) { shard.refresh("percolator_load_queries", true); // Maybe add a mode load? This isn't really a write. We need write b/c state=post_recovery - try (Engine.Searcher searcher = shard.acquireSearcher("percolator_load_queries", IndexShard.Mode.WRITE)) { + try (Engine.Searcher searcher = shard.acquireSearcher("percolator_load_queries", true)) { Query query = new ConstantScoreQuery( indexCache.filter().cache( new TermFilter(new Term(TypeFieldMapper.NAME, PercolatorService.TYPE_NAME)) diff --git a/src/main/java/org/elasticsearch/index/service/IndexService.java b/src/main/java/org/elasticsearch/index/service/IndexService.java deleted file mode 100644 index 4369b42bd93..00000000000 --- a/src/main/java/org/elasticsearch/index/service/IndexService.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.index.service; - -import com.google.common.collect.ImmutableSet; -import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.inject.Injector; -import org.elasticsearch.index.IndexComponent; -import org.elasticsearch.index.IndexShardMissingException; -import org.elasticsearch.index.aliases.IndexAliasesService; -import org.elasticsearch.index.analysis.AnalysisService; -import org.elasticsearch.index.cache.IndexCache; -import org.elasticsearch.index.cache.bitset.BitsetFilterCache; -import org.elasticsearch.index.engine.IndexEngine; -import org.elasticsearch.index.fielddata.IndexFieldDataService; -import org.elasticsearch.index.gateway.IndexGateway; -import org.elasticsearch.index.mapper.MapperService; -import org.elasticsearch.index.query.IndexQueryParserService; -import org.elasticsearch.index.settings.IndexSettingsService; -import org.elasticsearch.index.shard.service.IndexShard; -import org.elasticsearch.index.similarity.SimilarityService; -import org.elasticsearch.index.store.IndexStore; - -/** - * - */ -public interface IndexService extends IndexComponent, Iterable { - - Injector injector(); - - IndexGateway gateway(); - - IndexCache cache(); - - IndexFieldDataService fieldData(); - - BitsetFilterCache bitsetFilterCache(); - - IndexSettingsService settingsService(); - - AnalysisService analysisService(); - - MapperService mapperService(); - - IndexQueryParserService queryParserService(); - - SimilarityService similarityService(); - - IndexAliasesService aliasesService(); - - IndexEngine engine(); - - IndexStore store(); - - IndexShard createShard(int sShardId) throws ElasticsearchException; - - /** - * Removes the shard, does not delete local data or the gateway. - */ - void removeShard(int shardId, String reason) throws ElasticsearchException; - - int numberOfShards(); - - ImmutableSet shardIds(); - - boolean hasShard(int shardId); - - /** - * Return the shard with the provided id, or null if there is no such shard. - */ - @Nullable - IndexShard shard(int shardId); - - /** - * Return the shard with the provided id, or throw an exception if it doesn't exist. - */ - IndexShard shardSafe(int shardId) throws IndexShardMissingException; - - /** - * Return the shard injector for the provided id, or null if there is no such shard. - */ - @Nullable - Injector shardInjector(int shardId); - - /** - * Return the shard injector for the provided id, or throw an exception if there is no such shard. - */ - Injector shardInjectorSafe(int shardId) throws IndexShardMissingException; - - String indexUUID(); - -} diff --git a/src/main/java/org/elasticsearch/index/settings/IndexDynamicSettingsModule.java b/src/main/java/org/elasticsearch/index/settings/IndexDynamicSettingsModule.java index 5bbbcd8a93f..317a5ae7b79 100644 --- a/src/main/java/org/elasticsearch/index/settings/IndexDynamicSettingsModule.java +++ b/src/main/java/org/elasticsearch/index/settings/IndexDynamicSettingsModule.java @@ -35,7 +35,7 @@ import org.elasticsearch.index.merge.policy.LogDocMergePolicyProvider; import org.elasticsearch.index.merge.policy.TieredMergePolicyProvider; import org.elasticsearch.index.merge.scheduler.ConcurrentMergeSchedulerProvider; import org.elasticsearch.index.search.slowlog.ShardSlowLogSearchService; -import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.store.support.AbstractIndexStore; import org.elasticsearch.index.translog.TranslogService; import org.elasticsearch.index.translog.fs.FsTranslog; @@ -71,7 +71,7 @@ public class IndexDynamicSettingsModule extends AbstractModule { indexDynamicSettings.addDynamicSetting(IndexMetaData.SETTING_BLOCKS_WRITE); indexDynamicSettings.addDynamicSetting(IndexMetaData.SETTING_BLOCKS_METADATA); indexDynamicSettings.addDynamicSetting(IndicesTTLService.INDEX_TTL_DISABLE_PURGE); - indexDynamicSettings.addDynamicSetting(InternalIndexShard.INDEX_REFRESH_INTERVAL, Validator.TIME); + indexDynamicSettings.addDynamicSetting(IndexShard.INDEX_REFRESH_INTERVAL, Validator.TIME); indexDynamicSettings.addDynamicSetting(LocalGatewayAllocator.INDEX_RECOVERY_INITIAL_SHARDS); indexDynamicSettings.addDynamicSetting(LogByteSizeMergePolicyProvider.INDEX_MERGE_POLICY_MIN_MERGE_SIZE, Validator.BYTES_SIZE); indexDynamicSettings.addDynamicSetting(LogByteSizeMergePolicyProvider.INDEX_MERGE_POLICY_MAX_MERGE_SIZE, Validator.BYTES_SIZE); diff --git a/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java b/src/main/java/org/elasticsearch/index/shard/IndexShard.java similarity index 90% rename from src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java rename to src/main/java/org/elasticsearch/index/shard/IndexShard.java index e0c723da303..8842a9f5e45 100644 --- a/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java +++ b/src/main/java/org/elasticsearch/index/shard/IndexShard.java @@ -17,7 +17,7 @@ * under the License. */ -package org.elasticsearch.index.shard.service; +package org.elasticsearch.index.shard; import com.google.common.base.Charsets; import org.apache.lucene.codecs.PostingsFormat; @@ -86,21 +86,9 @@ import org.elasticsearch.index.refresh.RefreshStats; import org.elasticsearch.index.search.nested.NonNestedDocsFilter; import org.elasticsearch.index.search.stats.SearchStats; import org.elasticsearch.index.search.stats.ShardSearchService; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.settings.IndexSettingsService; -import org.elasticsearch.index.shard.AbstractIndexShardComponent; -import org.elasticsearch.index.shard.DocsStats; -import org.elasticsearch.index.shard.IllegalIndexShardStateException; -import org.elasticsearch.index.shard.IndexShardClosedException; -import org.elasticsearch.index.shard.IndexShardException; -import org.elasticsearch.index.shard.IndexShardNotRecoveringException; -import org.elasticsearch.index.shard.IndexShardNotStartedException; -import org.elasticsearch.index.shard.IndexShardRecoveringException; -import org.elasticsearch.index.shard.IndexShardRelocatedException; -import org.elasticsearch.index.shard.IndexShardStartedException; -import org.elasticsearch.index.shard.IndexShardState; -import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.store.Store; import org.elasticsearch.index.store.StoreStats; import org.elasticsearch.index.suggest.stats.ShardSuggestService; @@ -128,7 +116,7 @@ import static org.elasticsearch.index.mapper.SourceToParse.source; /** * */ -public class InternalIndexShard extends AbstractIndexShardComponent implements IndexShard { +public class IndexShard extends AbstractIndexShardComponent implements IndexShardComponent { private final ThreadPool threadPool; private final IndexSettingsService indexSettingsService; @@ -177,10 +165,10 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I private final MeanMetric flushMetric = new MeanMetric(); @Inject - public InternalIndexShard(ShardId shardId, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService, IndicesLifecycle indicesLifecycle, Store store, Engine engine, MergeSchedulerProvider mergeScheduler, Translog translog, - ThreadPool threadPool, MapperService mapperService, IndexQueryParserService queryParserService, IndexCache indexCache, IndexAliasesService indexAliasesService, ShardIndexingService indexingService, ShardGetService getService, ShardSearchService searchService, ShardIndexWarmerService shardWarmerService, - ShardFilterCache shardFilterCache, ShardFieldData shardFieldData, PercolatorQueriesRegistry percolatorQueriesRegistry, ShardPercolateService shardPercolateService, CodecService codecService, - ShardTermVectorsService termVectorsService, IndexFieldDataService indexFieldDataService, IndexService indexService, ShardSuggestService shardSuggestService, ShardQueryCache shardQueryCache, ShardBitsetFilterCache shardBitsetFilterCache) { + public IndexShard(ShardId shardId, @IndexSettings Settings indexSettings, IndexSettingsService indexSettingsService, IndicesLifecycle indicesLifecycle, Store store, Engine engine, MergeSchedulerProvider mergeScheduler, Translog translog, + ThreadPool threadPool, MapperService mapperService, IndexQueryParserService queryParserService, IndexCache indexCache, IndexAliasesService indexAliasesService, ShardIndexingService indexingService, ShardGetService getService, ShardSearchService searchService, ShardIndexWarmerService shardWarmerService, + ShardFilterCache shardFilterCache, ShardFieldData shardFieldData, PercolatorQueriesRegistry percolatorQueriesRegistry, ShardPercolateService shardPercolateService, CodecService codecService, + ShardTermVectorsService termVectorsService, IndexFieldDataService indexFieldDataService, IndexService indexService, ShardSuggestService shardSuggestService, ShardQueryCache shardQueryCache, ShardBitsetFilterCache shardBitsetFilterCache) { super(shardId, indexSettings); this.indicesLifecycle = (InternalIndicesLifecycle) indicesLifecycle; this.indexSettingsService = indexSettingsService; @@ -239,72 +227,63 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I return this.indexingService; } - @Override public ShardGetService getService() { return this.getService; } - @Override public ShardTermVectorsService termVectorsService() { return termVectorsService; } - @Override public ShardSuggestService shardSuggestService() { return shardSuggestService; } - @Override public ShardBitsetFilterCache shardBitsetFilterCache() { return shardBitsetFilterCache; } - @Override public IndexFieldDataService indexFieldDataService() { return indexFieldDataService; } - @Override public MapperService mapperService() { return mapperService; } - @Override public IndexService indexService() { return indexService; } - @Override public ShardSearchService searchService() { return this.searchService; } - @Override public ShardIndexWarmerService warmerService() { return this.shardWarmerService; } - @Override public ShardFilterCache filterCache() { return this.shardFilterCache; } - @Override public ShardQueryCache queryCache() { return this.shardQueryCache; } - @Override public ShardFieldData fieldData() { return this.shardFieldData; } - @Override + /** + * Returns the latest cluster routing entry received with this shard. Might be null if the + * shard was just created. + */ public ShardRouting routingEntry() { return this.shardRouting; } - public InternalIndexShard routingEntry(ShardRouting newRouting) { + public IndexShard routingEntry(ShardRouting newRouting) { ShardRouting currentRouting = this.shardRouting; if (!newRouting.shardId().equals(shardId())) { throw new ElasticsearchIllegalArgumentException("Trying to set a routing entry with shardId [" + newRouting.shardId() + "] on a shard with shardId [" + shardId() + "]"); @@ -377,7 +356,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I } } - public InternalIndexShard relocated(String reason) throws IndexShardNotStartedException { + public IndexShard relocated(String reason) throws IndexShardNotStartedException { synchronized (mutex) { if (state != IndexShardState.STARTED) { throw new IndexShardNotStartedException(shardId, state); @@ -387,7 +366,6 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I return this; } - @Override public IndexShardState state() { return state; } @@ -407,7 +385,6 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I return previousState; } - @Override public Engine.Create prepareCreate(SourceToParse source, long version, VersionType versionType, Engine.Operation.Origin origin, boolean canHaveDuplicates, boolean autoGeneratedId) throws ElasticsearchException { long startTime = System.nanoTime(); Tuple docMapper = mapperService.documentMapperWithAutoCreate(source.type()); @@ -415,7 +392,6 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I return new Engine.Create(docMapper.v1(), docMapper.v1().uidMapper().term(doc.uid().stringValue()), doc, version, versionType, origin, startTime, state != IndexShardState.STARTED || canHaveDuplicates, autoGeneratedId); } - @Override public ParsedDocument create(Engine.Create create) throws ElasticsearchException { writeAllowed(create.origin()); create = indexingService.preCreate(create); @@ -433,7 +409,6 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I return create.parsedDoc(); } - @Override public Engine.Index prepareIndex(SourceToParse source, long version, VersionType versionType, Engine.Operation.Origin origin, boolean canHaveDuplicates) throws ElasticsearchException { long startTime = System.nanoTime(); Tuple docMapper = mapperService.documentMapperWithAutoCreate(source.type()); @@ -441,7 +416,6 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I return new Engine.Index(docMapper.v1(), docMapper.v1().uidMapper().term(doc.uid().stringValue()), doc, version, versionType, origin, startTime, state != IndexShardState.STARTED || canHaveDuplicates); } - @Override public ParsedDocument index(Engine.Index index) throws ElasticsearchException { writeAllowed(index.origin()); index = indexingService.preIndex(index); @@ -459,14 +433,12 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I return index.parsedDoc(); } - @Override public Engine.Delete prepareDelete(String type, String id, long version, VersionType versionType, Engine.Operation.Origin origin) throws ElasticsearchException { long startTime = System.nanoTime(); DocumentMapper docMapper = mapperService.documentMapperWithAutoCreate(type).v1(); return new Engine.Delete(type, id, docMapper.uidMapper().term(type, id), version, versionType, origin, startTime, false); } - @Override public void delete(Engine.Delete delete) throws ElasticsearchException { writeAllowed(delete.origin()); delete = indexingService.preDelete(delete); @@ -483,7 +455,6 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I indexingService.postDelete(delete); } - @Override public Engine.DeleteByQuery prepareDeleteByQuery(BytesReference source, @Nullable String[] filteringAliases, Engine.Operation.Origin origin, String... types) throws ElasticsearchException { long startTime = System.nanoTime(); if (types == null) { @@ -497,7 +468,6 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I return new Engine.DeleteByQuery(query, source, filteringAliases, aliasFilter, parentFilter, origin, startTime, types); } - @Override public void deleteByQuery(Engine.DeleteByQuery deleteByQuery) throws ElasticsearchException { writeAllowed(deleteByQuery.origin()); if (logger.isTraceEnabled()) { @@ -509,13 +479,11 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I indexingService.postDeleteByQuery(deleteByQuery); } - @Override public Engine.GetResult get(Engine.Get get) throws ElasticsearchException { readAllowed(); return engine.get(get); } - @Override public void refresh(String source, boolean force) throws ElasticsearchException { verifyNotClosed(); if (logger.isTraceEnabled()) { @@ -526,17 +494,14 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I refreshMetric.inc(System.nanoTime() - time); } - @Override public RefreshStats refreshStats() { return new RefreshStats(refreshMetric.count(), TimeUnit.NANOSECONDS.toMillis(refreshMetric.sum())); } - @Override public FlushStats flushStats() { return new FlushStats(flushMetric.count(), TimeUnit.NANOSECONDS.toMillis(flushMetric.sum())); } - @Override public DocsStats docStats() { final Engine.Searcher searcher = acquireSearcher("doc_stats"); try { @@ -546,22 +511,18 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I } } - @Override public IndexingStats indexingStats(String... types) { return indexingService.stats(types); } - @Override public SearchStats searchStats(String... groups) { return searchService.stats(groups); } - @Override public GetStats getStats() { return getService.stats(); } - @Override public StoreStats storeStats() { try { return store.stats(); @@ -572,60 +533,49 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I } } - @Override public MergeStats mergeStats() { return mergeScheduler.stats(); } - @Override public SegmentsStats segmentStats() { SegmentsStats segmentsStats = engine.segmentsStats(); segmentsStats.addBitsetMemoryInBytes(shardBitsetFilterCache.getMemorySizeInBytes()); return segmentsStats; } - @Override public WarmerStats warmerStats() { return shardWarmerService.stats(); } - @Override public FilterCacheStats filterCacheStats() { return shardFilterCache.stats(); } - @Override public FieldDataStats fieldDataStats(String... fields) { return shardFieldData.stats(fields); } - @Override public PercolatorQueriesRegistry percolateRegistry() { return percolatorQueriesRegistry; } - @Override public ShardPercolateService shardPercolateService() { return shardPercolateService; } - @Override public IdCacheStats idCacheStats() { long memorySizeInBytes = shardFieldData.stats(ParentFieldMapper.NAME).getFields().get(ParentFieldMapper.NAME); return new IdCacheStats(memorySizeInBytes); } - @Override public TranslogStats translogStats() { return translog.stats(); } - @Override public SuggestStats suggestStats() { return shardSuggestService.stats(); } - @Override public CompletionStats completionStats(String... fields) { CompletionStats completionStats = new CompletionStats(); final Engine.Searcher currentSearcher = acquireSearcher("completion_stats"); @@ -641,7 +591,6 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I return completionStats; } - @Override public void flush(FlushRequest request) throws ElasticsearchException { // we allows flush while recovering, since we allow for operations to happen // while recovering, and we want to keep the translog at bay (up to deletes, which @@ -655,7 +604,6 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I flushMetric.inc(System.nanoTime() - time); } - @Override public void optimize(OptimizeRequest optimize) throws ElasticsearchException { verifyStarted(); if (logger.isTraceEnabled()) { @@ -675,26 +623,22 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I } } - @Override public void recover(Engine.RecoveryHandler recoveryHandler) throws EngineException { verifyStarted(); engine.recover(recoveryHandler); } - @Override public void failShard(String reason, Throwable e) { // fail the engine. This will cause this shard to also be removed from the node's index service. engine.failEngine(reason, e); } - @Override public Engine.Searcher acquireSearcher(String source) { - return acquireSearcher(source, Mode.READ); + return acquireSearcher(source, false); } - @Override - public Engine.Searcher acquireSearcher(String source, Mode mode) { - readAllowed(mode); + public Engine.Searcher acquireSearcher(String source, boolean searcherForWriteOperation) { + readAllowed(searcherForWriteOperation); return engine.acquireSearcher(source); } @@ -716,7 +660,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I } - public InternalIndexShard postRecovery(String reason) throws IndexShardStartedException, IndexShardRelocatedException, IndexShardClosedException { + public IndexShard postRecovery(String reason) throws IndexShardStartedException, IndexShardRelocatedException, IndexShardClosedException { synchronized (mutex) { if (state == IndexShardState.CLOSED) { throw new IndexShardClosedException(shardId); @@ -854,23 +798,20 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I } public void readAllowed() throws IllegalIndexShardStateException { - readAllowed(Mode.READ); + readAllowed(false); } - public void readAllowed(Mode mode) throws IllegalIndexShardStateException { + private void readAllowed(boolean writeOperation) throws IllegalIndexShardStateException { IndexShardState state = this.state; // one time volatile read - switch (mode) { - case READ: - if (state != IndexShardState.STARTED && state != IndexShardState.RELOCATED) { - throw new IllegalIndexShardStateException(shardId, state, "operations only allowed when started/relocated"); - } - break; - case WRITE: - if (state != IndexShardState.STARTED && state != IndexShardState.RELOCATED && state != IndexShardState.RECOVERING && state != IndexShardState.POST_RECOVERY) { - throw new IllegalIndexShardStateException(shardId, state, "operations only allowed when started/relocated"); - } - break; + if (writeOperation) { + if (state != IndexShardState.STARTED && state != IndexShardState.RELOCATED && state != IndexShardState.RECOVERING && state != IndexShardState.POST_RECOVERY) { + throw new IllegalIndexShardStateException(shardId, state, "operations only allowed when started/relocated"); + } + } else { + if (state != IndexShardState.STARTED && state != IndexShardState.RELOCATED) { + throw new IllegalIndexShardStateException(shardId, state, "operations only allowed when started/relocated"); + } } } @@ -939,9 +880,9 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I if (state == IndexShardState.CLOSED) { return; } - TimeValue refreshInterval = settings.getAsTime(INDEX_REFRESH_INTERVAL, InternalIndexShard.this.refreshInterval); - if (!refreshInterval.equals(InternalIndexShard.this.refreshInterval)) { - logger.info("updating refresh_interval from [{}] to [{}]", InternalIndexShard.this.refreshInterval, refreshInterval); + TimeValue refreshInterval = settings.getAsTime(INDEX_REFRESH_INTERVAL, IndexShard.this.refreshInterval); + if (!refreshInterval.equals(IndexShard.this.refreshInterval)) { + logger.info("updating refresh_interval from [{}] to [{}]", IndexShard.this.refreshInterval, refreshInterval); if (refreshScheduledFuture != null) { // NOTE: we pass false here so we do NOT attempt Thread.interrupt if EngineRefresher.run is currently running. This is // very important, because doing so can cause files to suddenly be closed if they were doing IO when the interrupt @@ -949,7 +890,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I FutureUtils.cancel(refreshScheduledFuture); refreshScheduledFuture = null; } - InternalIndexShard.this.refreshInterval = refreshInterval; + IndexShard.this.refreshInterval = refreshInterval; if (refreshInterval.millis() > 0) { refreshScheduledFuture = threadPool.schedule(refreshInterval, ThreadPool.Names.SAME, new EngineRefresher()); } diff --git a/src/main/java/org/elasticsearch/index/shard/IndexShardModule.java b/src/main/java/org/elasticsearch/index/shard/IndexShardModule.java index 33033332d23..916031e8f2c 100644 --- a/src/main/java/org/elasticsearch/index/shard/IndexShardModule.java +++ b/src/main/java/org/elasticsearch/index/shard/IndexShardModule.java @@ -21,8 +21,6 @@ package org.elasticsearch.index.shard; import org.elasticsearch.common.inject.AbstractModule; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.shard.service.IndexShard; -import org.elasticsearch.index.shard.service.InternalIndexShard; import org.elasticsearch.index.warmer.ShardIndexWarmerService; /** @@ -30,19 +28,16 @@ import org.elasticsearch.index.warmer.ShardIndexWarmerService; */ public class IndexShardModule extends AbstractModule { - private final Settings settings; - private final ShardId shardId; - public IndexShardModule(Settings settings, ShardId shardId) { - this.settings = settings; + public IndexShardModule(ShardId shardId) { this.shardId = shardId; } @Override protected void configure() { bind(ShardId.class).toInstance(shardId); - bind(IndexShard.class).to(InternalIndexShard.class).asEagerSingleton(); + bind(IndexShard.class).asEagerSingleton(); bind(ShardIndexWarmerService.class).asEagerSingleton(); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/shard/service/IndexShard.java b/src/main/java/org/elasticsearch/index/shard/service/IndexShard.java deleted file mode 100644 index a4b5d155f7c..00000000000 --- a/src/main/java/org/elasticsearch/index/shard/service/IndexShard.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.index.shard.service; - -import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.action.admin.indices.flush.FlushRequest; -import org.elasticsearch.action.admin.indices.optimize.OptimizeRequest; -import org.elasticsearch.cluster.routing.ShardRouting; -import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.bytes.BytesReference; -import org.elasticsearch.index.VersionType; -import org.elasticsearch.index.cache.bitset.ShardBitsetFilterCache; -import org.elasticsearch.index.cache.filter.FilterCacheStats; -import org.elasticsearch.index.cache.filter.ShardFilterCache; -import org.elasticsearch.index.cache.id.IdCacheStats; -import org.elasticsearch.index.cache.query.ShardQueryCache; -import org.elasticsearch.index.deletionpolicy.SnapshotIndexCommit; -import org.elasticsearch.index.engine.Engine; -import org.elasticsearch.index.engine.EngineException; -import org.elasticsearch.index.engine.SegmentsStats; -import org.elasticsearch.index.fielddata.FieldDataStats; -import org.elasticsearch.index.fielddata.IndexFieldDataService; -import org.elasticsearch.index.fielddata.ShardFieldData; -import org.elasticsearch.index.flush.FlushStats; -import org.elasticsearch.index.get.GetStats; -import org.elasticsearch.index.get.ShardGetService; -import org.elasticsearch.index.indexing.IndexingStats; -import org.elasticsearch.index.indexing.ShardIndexingService; -import org.elasticsearch.index.mapper.MapperService; -import org.elasticsearch.index.mapper.ParsedDocument; -import org.elasticsearch.index.mapper.SourceToParse; -import org.elasticsearch.index.merge.MergeStats; -import org.elasticsearch.index.percolator.PercolatorQueriesRegistry; -import org.elasticsearch.index.percolator.stats.ShardPercolateService; -import org.elasticsearch.index.refresh.RefreshStats; -import org.elasticsearch.index.search.stats.SearchStats; -import org.elasticsearch.index.search.stats.ShardSearchService; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.*; -import org.elasticsearch.index.store.StoreStats; -import org.elasticsearch.index.suggest.stats.ShardSuggestService; -import org.elasticsearch.index.suggest.stats.SuggestStats; -import org.elasticsearch.index.termvectors.ShardTermVectorsService; -import org.elasticsearch.index.translog.TranslogStats; -import org.elasticsearch.index.warmer.ShardIndexWarmerService; -import org.elasticsearch.index.warmer.WarmerStats; -import org.elasticsearch.search.suggest.completion.CompletionStats; - -/** - * - */ -public interface IndexShard extends IndexShardComponent { - - ShardIndexingService indexingService(); - - ShardGetService getService(); - - ShardSearchService searchService(); - - ShardIndexWarmerService warmerService(); - - ShardFilterCache filterCache(); - - ShardQueryCache queryCache(); - - ShardFieldData fieldData(); - - /** - * Returns the latest cluster routing entry received with this shard. Might be null if the - * shard was just created. - */ - @Nullable - ShardRouting routingEntry(); - - DocsStats docStats(); - - StoreStats storeStats(); - - IndexingStats indexingStats(String... types); - - SearchStats searchStats(String... groups); - - GetStats getStats(); - - MergeStats mergeStats(); - - SegmentsStats segmentStats(); - - RefreshStats refreshStats(); - - FlushStats flushStats(); - - WarmerStats warmerStats(); - - FilterCacheStats filterCacheStats(); - - IdCacheStats idCacheStats(); - - FieldDataStats fieldDataStats(String... fields); - - CompletionStats completionStats(String... fields); - - TranslogStats translogStats(); - - SuggestStats suggestStats(); - - PercolatorQueriesRegistry percolateRegistry(); - - ShardPercolateService shardPercolateService(); - - ShardTermVectorsService termVectorsService(); - - ShardSuggestService shardSuggestService(); - - ShardBitsetFilterCache shardBitsetFilterCache(); - - MapperService mapperService(); - - IndexFieldDataService indexFieldDataService(); - - IndexService indexService(); - - IndexShardState state(); - - Engine.Create prepareCreate(SourceToParse source, long version, VersionType versionType, Engine.Operation.Origin origin, boolean canHaveDuplicates, boolean autoGeneratedId) throws ElasticsearchException; - - ParsedDocument create(Engine.Create create) throws ElasticsearchException; - - Engine.Index prepareIndex(SourceToParse source, long version, VersionType versionType, Engine.Operation.Origin origin, boolean canHaveDuplicates) throws ElasticsearchException; - - ParsedDocument index(Engine.Index index) throws ElasticsearchException; - - Engine.Delete prepareDelete(String type, String id, long version, VersionType versionType, Engine.Operation.Origin origin) throws ElasticsearchException; - - void delete(Engine.Delete delete) throws ElasticsearchException; - - Engine.DeleteByQuery prepareDeleteByQuery(BytesReference source, @Nullable String[] filteringAliases, Engine.Operation.Origin origin, String... types) throws ElasticsearchException; - - void deleteByQuery(Engine.DeleteByQuery deleteByQuery) throws ElasticsearchException; - - Engine.GetResult get(Engine.Get get) throws ElasticsearchException; - - void refresh(String source, boolean force) throws ElasticsearchException; - - void flush(FlushRequest request) throws ElasticsearchException; - - void optimize(OptimizeRequest optimize) throws ElasticsearchException; - - void recover(Engine.RecoveryHandler recoveryHandler) throws EngineException; - - void failShard(String reason, @Nullable Throwable e); - - Engine.Searcher acquireSearcher(String source); - - Engine.Searcher acquireSearcher(String source, Mode mode); - - /** - * Returns true if this shard can ignore a recovery attempt made to it (since the already doing/done it) - */ - public boolean ignoreRecoveryAttempt(); - - void readAllowed() throws IllegalIndexShardStateException; - - ShardId shardId(); - - public enum Mode { - READ, - WRITE - } -} diff --git a/src/main/java/org/elasticsearch/index/snapshots/IndexShardSnapshotAndRestoreService.java b/src/main/java/org/elasticsearch/index/snapshots/IndexShardSnapshotAndRestoreService.java index 5a4687b8c04..816de5bea01 100644 --- a/src/main/java/org/elasticsearch/index/snapshots/IndexShardSnapshotAndRestoreService.java +++ b/src/main/java/org/elasticsearch/index/snapshots/IndexShardSnapshotAndRestoreService.java @@ -33,8 +33,7 @@ import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.shard.AbstractIndexShardComponent; import org.elasticsearch.index.shard.IndexShardState; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; -import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.snapshots.RestoreService; @@ -46,7 +45,7 @@ import org.elasticsearch.snapshots.RestoreService; */ public class IndexShardSnapshotAndRestoreService extends AbstractIndexShardComponent { - private final InternalIndexShard indexShard; + private final IndexShard indexShard; private final RepositoriesService repositoriesService; @@ -55,7 +54,7 @@ public class IndexShardSnapshotAndRestoreService extends AbstractIndexShardCompo @Inject public IndexShardSnapshotAndRestoreService(ShardId shardId, @IndexSettings Settings indexSettings, IndexShard indexShard, RepositoriesService repositoriesService, RestoreService restoreService) { super(shardId, indexSettings); - this.indexShard = (InternalIndexShard) indexShard; + this.indexShard = indexShard; this.repositoriesService = repositoriesService; this.restoreService = restoreService; } diff --git a/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardRepository.java b/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardRepository.java index 6506f0aaec1..1c90b795865 100644 --- a/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardRepository.java +++ b/src/main/java/org/elasticsearch/index/snapshots/blobstore/BlobStoreIndexShardRepository.java @@ -48,7 +48,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.xcontent.*; import org.elasticsearch.index.deletionpolicy.SnapshotIndexCommit; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.snapshots.*; import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot.FileInfo; diff --git a/src/main/java/org/elasticsearch/index/store/fs/DefaultFsIndexStore.java b/src/main/java/org/elasticsearch/index/store/fs/DefaultFsIndexStore.java index 8d6cd003d8c..ccd8369a58e 100644 --- a/src/main/java/org/elasticsearch/index/store/fs/DefaultFsIndexStore.java +++ b/src/main/java/org/elasticsearch/index/store/fs/DefaultFsIndexStore.java @@ -23,7 +23,7 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.index.Index; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.store.DirectoryService; import org.elasticsearch.index.store.support.AbstractIndexStore; diff --git a/src/main/java/org/elasticsearch/index/store/fs/MmapFsIndexStore.java b/src/main/java/org/elasticsearch/index/store/fs/MmapFsIndexStore.java index e0c394c990f..444cd67b713 100644 --- a/src/main/java/org/elasticsearch/index/store/fs/MmapFsIndexStore.java +++ b/src/main/java/org/elasticsearch/index/store/fs/MmapFsIndexStore.java @@ -23,7 +23,7 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.index.Index; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.store.DirectoryService; import org.elasticsearch.index.store.support.AbstractIndexStore; diff --git a/src/main/java/org/elasticsearch/index/store/fs/NioFsIndexStore.java b/src/main/java/org/elasticsearch/index/store/fs/NioFsIndexStore.java index f639c4846f5..7f5cece99b6 100644 --- a/src/main/java/org/elasticsearch/index/store/fs/NioFsIndexStore.java +++ b/src/main/java/org/elasticsearch/index/store/fs/NioFsIndexStore.java @@ -23,7 +23,7 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.index.Index; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.store.DirectoryService; import org.elasticsearch.index.store.support.AbstractIndexStore; diff --git a/src/main/java/org/elasticsearch/index/store/fs/SimpleFsIndexStore.java b/src/main/java/org/elasticsearch/index/store/fs/SimpleFsIndexStore.java index 3cd8f227881..1a9f40b9779 100644 --- a/src/main/java/org/elasticsearch/index/store/fs/SimpleFsIndexStore.java +++ b/src/main/java/org/elasticsearch/index/store/fs/SimpleFsIndexStore.java @@ -23,7 +23,7 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.index.Index; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.store.DirectoryService; import org.elasticsearch.index.store.support.AbstractIndexStore; diff --git a/src/main/java/org/elasticsearch/index/store/support/AbstractIndexStore.java b/src/main/java/org/elasticsearch/index/store/support/AbstractIndexStore.java index b21d68b9a0c..689c6e6d9d2 100644 --- a/src/main/java/org/elasticsearch/index/store/support/AbstractIndexStore.java +++ b/src/main/java/org/elasticsearch/index/store/support/AbstractIndexStore.java @@ -28,7 +28,7 @@ import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.index.AbstractIndexComponent; import org.elasticsearch.index.Index; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.settings.IndexSettingsService; import org.elasticsearch.index.shard.ShardId; diff --git a/src/main/java/org/elasticsearch/index/termvectors/ShardTermVectorsService.java b/src/main/java/org/elasticsearch/index/termvectors/ShardTermVectorsService.java index 5b6a68471a6..133e3663800 100644 --- a/src/main/java/org/elasticsearch/index/termvectors/ShardTermVectorsService.java +++ b/src/main/java/org/elasticsearch/index/termvectors/ShardTermVectorsService.java @@ -42,11 +42,11 @@ import org.elasticsearch.index.get.GetResult; import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.core.StringFieldMapper; import org.elasticsearch.index.mapper.internal.UidFieldMapper; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.shard.AbstractIndexShardComponent; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.search.dfs.AggregatedDfs; import java.io.IOException; diff --git a/src/main/java/org/elasticsearch/index/translog/TranslogService.java b/src/main/java/org/elasticsearch/index/translog/TranslogService.java index 3c3c6bf85e1..03ab20621ff 100644 --- a/src/main/java/org/elasticsearch/index/translog/TranslogService.java +++ b/src/main/java/org/elasticsearch/index/translog/TranslogService.java @@ -26,7 +26,6 @@ import org.elasticsearch.common.unit.ByteSizeUnit; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.FutureUtils; -import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.engine.FlushNotAllowedEngineException; import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.settings.IndexSettingsService; @@ -34,7 +33,7 @@ import org.elasticsearch.index.shard.AbstractIndexShardComponent; import org.elasticsearch.index.shard.IllegalIndexShardStateException; import org.elasticsearch.index.shard.IndexShardState; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.threadpool.ThreadPool; import java.util.concurrent.ScheduledFuture; diff --git a/src/main/java/org/elasticsearch/indices/IndicesLifecycle.java b/src/main/java/org/elasticsearch/indices/IndicesLifecycle.java index 5d9bf0ce9b2..77f1b160606 100644 --- a/src/main/java/org/elasticsearch/indices/IndicesLifecycle.java +++ b/src/main/java/org/elasticsearch/indices/IndicesLifecycle.java @@ -22,10 +22,10 @@ package org.elasticsearch.indices; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.Nullable; import org.elasticsearch.index.Index; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.IndexShardState; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; /** * A global component allowing to register for lifecycle of an index (create/closed) and @@ -161,7 +161,7 @@ public interface IndicesLifecycle { /** * Called before the index gets deleted. * This listener method is invoked after - * {@link #beforeIndexClosed(org.elasticsearch.index.service.IndexService)} when an index is deleted + * {@link #beforeIndexClosed(org.elasticsearch.index.IndexService)} when an index is deleted * * @param indexService The index service */ diff --git a/src/main/java/org/elasticsearch/indices/IndicesModule.java b/src/main/java/org/elasticsearch/indices/IndicesModule.java index fa7513687c6..ae9ad6155a3 100644 --- a/src/main/java/org/elasticsearch/indices/IndicesModule.java +++ b/src/main/java/org/elasticsearch/indices/IndicesModule.java @@ -63,7 +63,7 @@ public class IndicesModule extends AbstractModule implements SpawnModules { protected void configure() { bind(IndicesLifecycle.class).to(InternalIndicesLifecycle.class).asEagerSingleton(); - bind(IndicesService.class).to(InternalIndicesService.class).asEagerSingleton(); + bind(IndicesService.class).asEagerSingleton(); bind(RecoverySettings.class).asEagerSingleton(); bind(RecoveryTarget.class).asEagerSingleton(); diff --git a/src/main/java/org/elasticsearch/indices/IndicesService.java b/src/main/java/org/elasticsearch/indices/IndicesService.java index 33d97ed5e13..9ef3a1f8f5e 100644 --- a/src/main/java/org/elasticsearch/indices/IndicesService.java +++ b/src/main/java/org/elasticsearch/indices/IndicesService.java @@ -19,48 +19,260 @@ package org.elasticsearch.indices; -import com.google.common.collect.ImmutableMap; +import com.google.common.base.Function; +import com.google.common.collect.*; +import org.apache.lucene.util.IOUtils; import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.ElasticsearchIllegalStateException; +import org.elasticsearch.action.admin.indices.stats.CommonStats; import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags; +import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags.Flag; +import org.elasticsearch.action.admin.indices.stats.IndexShardStats; +import org.elasticsearch.action.admin.indices.stats.ShardStats; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.component.LifecycleComponent; +import org.elasticsearch.common.component.AbstractLifecycleComponent; +import org.elasticsearch.common.inject.*; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.Index; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.common.util.concurrent.EsExecutors; +import org.elasticsearch.env.NodeEnvironment; +import org.elasticsearch.gateway.Gateway; +import org.elasticsearch.index.*; +import org.elasticsearch.index.aliases.IndexAliasesServiceModule; +import org.elasticsearch.index.analysis.AnalysisModule; +import org.elasticsearch.index.analysis.AnalysisService; +import org.elasticsearch.index.cache.IndexCache; +import org.elasticsearch.index.cache.IndexCacheModule; +import org.elasticsearch.index.codec.CodecModule; +import org.elasticsearch.index.engine.IndexEngine; +import org.elasticsearch.index.engine.IndexEngineModule; +import org.elasticsearch.index.fielddata.IndexFieldDataModule; +import org.elasticsearch.index.fielddata.IndexFieldDataService; +import org.elasticsearch.index.flush.FlushStats; +import org.elasticsearch.index.gateway.IndexGateway; +import org.elasticsearch.index.gateway.IndexGatewayModule; +import org.elasticsearch.index.get.GetStats; +import org.elasticsearch.index.indexing.IndexingStats; +import org.elasticsearch.index.mapper.MapperService; +import org.elasticsearch.index.mapper.MapperServiceModule; +import org.elasticsearch.index.merge.MergeStats; +import org.elasticsearch.index.query.IndexQueryParserModule; +import org.elasticsearch.index.query.IndexQueryParserService; +import org.elasticsearch.index.refresh.RefreshStats; +import org.elasticsearch.index.search.stats.SearchStats; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.settings.IndexSettingsModule; +import org.elasticsearch.index.shard.IllegalIndexShardStateException; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.store.Store; +import org.elasticsearch.index.shard.IndexShard; +import org.elasticsearch.index.similarity.SimilarityModule; +import org.elasticsearch.index.store.IndexStore; +import org.elasticsearch.index.store.IndexStoreModule; +import org.elasticsearch.indices.analysis.IndicesAnalysisService; +import org.elasticsearch.indices.recovery.RecoverySettings; +import org.elasticsearch.indices.store.IndicesStore; +import org.elasticsearch.plugins.IndexPluginsModule; +import org.elasticsearch.plugins.PluginsService; +import java.io.Closeable; +import java.io.IOException; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +import static com.google.common.collect.Maps.newHashMap; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; +import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; +import static org.elasticsearch.common.collect.MapBuilder.newMapBuilder; +import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; /** * */ -public interface IndicesService extends Iterable, LifecycleComponent { +public class IndicesService extends AbstractLifecycleComponent implements Iterable { - /** - * Returns true if changes (adding / removing) indices, shards and so on are allowed. - */ - public boolean changesAllowed(); + private final InternalIndicesLifecycle indicesLifecycle; + + private final IndicesAnalysisService indicesAnalysisService; + + private IndicesStore indicesStore; + + private final Injector injector; + + private final PluginsService pluginsService; + + private final NodeEnvironment nodeEnv; + + private final Map indicesInjectors = new HashMap<>(); + + private volatile ImmutableMap indices = ImmutableMap.of(); + + private final OldShardsStats oldShardsStats = new OldShardsStats(); + + @Inject + public IndicesService(Settings settings, IndicesLifecycle indicesLifecycle, IndicesAnalysisService indicesAnalysisService, Injector injector, NodeEnvironment nodeEnv) { + super(settings); + this.indicesLifecycle = (InternalIndicesLifecycle) indicesLifecycle; + this.indicesAnalysisService = indicesAnalysisService; + this.injector = injector; + + this.pluginsService = injector.getInstance(PluginsService.class); + + this.indicesLifecycle.addListener(oldShardsStats); + this.nodeEnv = nodeEnv; + } + + @Inject + void setIndicesStore(IndicesStore store) { + this.indicesStore = store; + } + + @Override + protected void doStart() throws ElasticsearchException { + } + + @Override + protected void doStop() throws ElasticsearchException { + ImmutableSet indices = ImmutableSet.copyOf(this.indices.keySet()); + final CountDownLatch latch = new CountDownLatch(indices.size()); + + final ExecutorService indicesStopExecutor = Executors.newFixedThreadPool(5, EsExecutors.daemonThreadFactory("indices_shutdown")); + + for (final String index : indices) { + indicesStopExecutor.execute(new Runnable() { + @Override + public void run() { + try { + removeIndex(index, "shutdown", false, new IndexCloseListener() { + @Override + public void onAllShardsClosed(Index index, List failures) { + latch.countDown(); + } + + @Override + public void onShardClosed(ShardId shardId) { + } + + @Override + public void onShardCloseFailed(ShardId shardId, Throwable t) { + } + }); + } catch (Throwable e) { + latch.countDown(); + logger.warn("failed to delete index on stop [" + index + "]", e); + } + } + }); + } + try { + if (latch.await(30, TimeUnit.SECONDS) == false) { + logger.warn("Not all shards are closed yet, waited 30sec - stopping service"); + } + } catch (InterruptedException e) { + // ignore + } finally { + indicesStopExecutor.shutdown(); + } + } + + @Override + protected void doClose() throws ElasticsearchException { + injector.getInstance(RecoverySettings.class).close(); + indicesStore.close(); + indicesAnalysisService.close(); + } + + public IndicesLifecycle indicesLifecycle() { + return this.indicesLifecycle; + } /** * Returns the node stats indices stats. The includePrevious flag controls * if old shards stats will be aggregated as well (only for relevant stats, such as * refresh and indexing, not for docs/store). */ - NodeIndicesStats stats(boolean includePrevious); + public NodeIndicesStats stats(boolean includePrevious) { + return stats(true, new CommonStatsFlags().all()); + } - NodeIndicesStats stats(boolean includePrevious, CommonStatsFlags flags); + public NodeIndicesStats stats(boolean includePrevious, CommonStatsFlags flags) { + CommonStats oldStats = new CommonStats(flags); - boolean hasIndex(String index); + if (includePrevious) { + Flag[] setFlags = flags.getFlags(); + for (Flag flag : setFlags) { + switch (flag) { + case Get: + oldStats.get.add(oldShardsStats.getStats); + break; + case Indexing: + oldStats.indexing.add(oldShardsStats.indexingStats); + break; + case Search: + oldStats.search.add(oldShardsStats.searchStats); + break; + case Merge: + oldStats.merge.add(oldShardsStats.mergeStats); + break; + case Refresh: + oldStats.refresh.add(oldShardsStats.refreshStats); + break; + case Flush: + oldStats.flush.add(oldShardsStats.flushStats); + break; + } + } + } - IndicesLifecycle indicesLifecycle(); + Map> statsByShard = Maps.newHashMap(); + for (IndexService indexService : indices.values()) { + for (IndexShard indexShard : indexService) { + try { + if (indexShard.routingEntry() == null) { + continue; + } + IndexShardStats indexShardStats = new IndexShardStats(indexShard.shardId(), new ShardStats[] { new ShardStats(indexShard, indexShard.routingEntry(), flags) }); + if (!statsByShard.containsKey(indexService.index())) { + statsByShard.put(indexService.index(), Lists.newArrayList(indexShardStats)); + } else { + statsByShard.get(indexService.index()).add(indexShardStats); + } + } catch (IllegalIndexShardStateException e) { + // we can safely ignore illegal state on ones that are closing for example + } + } + } + return new NodeIndicesStats(oldStats, statsByShard); + } + + /** + * Returns true if changes (adding / removing) indices, shards and so on are allowed. + */ + public boolean changesAllowed() { + // we check on stop here since we defined stop when we delete the indices + return lifecycle.started(); + } + + @Override + public UnmodifiableIterator iterator() { + return indices.values().iterator(); + } + + public boolean hasIndex(String index) { + return indices.containsKey(index); + } /** * Returns a snapshot of the started indices and the associated {@link IndexService} instances. * * The map being returned is not a live view and subsequent calls can return a different view. */ - ImmutableMap indices(); + public ImmutableMap indices() { + return indices; + } /** * Returns an IndexService for the specified index if exists otherwise returns null. @@ -69,14 +281,77 @@ public interface IndicesService extends Iterable, LifecycleCompone * index maybe removed in the meantime, so preferable use the associated {@link IndexService} in order to prevent NPE. */ @Nullable - IndexService indexService(String index); + public IndexService indexService(String index) { + return indices.get(index); + } /** * Returns an IndexService for the specified index if exists otherwise a {@link IndexMissingException} is thrown. */ - IndexService indexServiceSafe(String index) throws IndexMissingException; + public IndexService indexServiceSafe(String index) throws IndexMissingException { + IndexService indexService = indexService(index); + if (indexService == null) { + throw new IndexMissingException(new Index(index)); + } + return indexService; + } - IndexService createIndex(String index, Settings settings, String localNodeId) throws ElasticsearchException; + public synchronized IndexService createIndex(String sIndexName, Settings settings, String localNodeId) throws ElasticsearchException { + if (!lifecycle.started()) { + throw new ElasticsearchIllegalStateException("Can't create an index [" + sIndexName + "], node is closed"); + } + Index index = new Index(sIndexName); + if (indicesInjectors.containsKey(index.name())) { + throw new IndexAlreadyExistsException(index); + } + + indicesLifecycle.beforeIndexCreated(index); + + logger.debug("creating Index [{}], shards [{}]/[{}]", sIndexName, settings.get(SETTING_NUMBER_OF_SHARDS), settings.get(SETTING_NUMBER_OF_REPLICAS)); + + Settings indexSettings = settingsBuilder() + .put(this.settings) + .put(settings) + .classLoader(settings.getClassLoader()) + .build(); + + ModulesBuilder modules = new ModulesBuilder(); + modules.add(new IndexNameModule(index)); + modules.add(new LocalNodeIdModule(localNodeId)); + modules.add(new IndexSettingsModule(index, indexSettings)); + modules.add(new IndexPluginsModule(indexSettings, pluginsService)); + modules.add(new IndexStoreModule(indexSettings)); + modules.add(new IndexEngineModule(indexSettings)); + modules.add(new AnalysisModule(indexSettings, indicesAnalysisService)); + modules.add(new SimilarityModule(indexSettings)); + modules.add(new IndexCacheModule(indexSettings)); + modules.add(new IndexFieldDataModule(indexSettings)); + modules.add(new CodecModule(indexSettings)); + modules.add(new MapperServiceModule()); + modules.add(new IndexQueryParserModule(indexSettings)); + modules.add(new IndexAliasesServiceModule()); + modules.add(new IndexGatewayModule(indexSettings, injector.getInstance(Gateway.class))); + modules.add(new IndexModule(indexSettings)); + + Injector indexInjector; + try { + indexInjector = modules.createChildInjector(injector); + } catch (CreationException e) { + throw new IndexCreationException(index, Injectors.getFirstErrorFailure(e)); + } catch (Throwable e) { + throw new IndexCreationException(index, e); + } + + indicesInjectors.put(index.name(), indexInjector); + + IndexService indexService = indexInjector.getInstance(IndexService.class); + + indicesLifecycle.afterIndexCreated(indexService); + + indices = newMapBuilder(indices).put(index.name(), indexService).immutableMap(); + + return indexService; + } /** * Removes the given index from this service and releases all associated resources. Persistent parts of the index @@ -84,7 +359,9 @@ public interface IndicesService extends Iterable, LifecycleCompone * @param index the index to remove * @param reason the high level reason causing this removal */ - void removeIndex(String index, String reason) throws ElasticsearchException; + public void removeIndex(String index, String reason) throws ElasticsearchException { + removeIndex(index, reason, false, null); + } /** * Deletes the given index. Persistent parts of the index @@ -95,7 +372,122 @@ public interface IndicesService extends Iterable, LifecycleCompone * @param index the index to delete * @param reason the high level reason causing this delete */ - void deleteIndex(String index, String reason) throws ElasticsearchException; + public void deleteIndex(String index, String reason) throws ElasticsearchException { + removeIndex(index, reason, true, new IndexCloseListener() { + + @Override + public void onAllShardsClosed(Index index, List failures) { + try { + nodeEnv.deleteIndexDirectorySafe(index); + logger.debug("deleted index [{}] from filesystem - failures {}", index, failures); + } catch (Exception e) { + for (Throwable t : failures) { + e.addSuppressed(t); + } + logger.debug("failed to deleted index [{}] from filesystem", e, index); + // ignore - still some shards locked here + } + } + + @Override + public void onShardClosed(ShardId shardId) { + try { + // this is called under the shard lock - we can safely delete it + IOUtils.rm(nodeEnv.shardPaths(shardId)); + logger.debug("deleted shard [{}] from filesystem", shardId); + } catch (IOException e) { + logger.warn("Can't delete shard {} ", e, shardId); + } + } + + @Override + public void onShardCloseFailed(ShardId shardId, Throwable t) { + } + }); + } + + private void removeIndex(String index, String reason, boolean delete, @Nullable IndexCloseListener listener) throws ElasticsearchException { + try { + final IndexService indexService; + final Injector indexInjector; + synchronized (this) { + indexInjector = indicesInjectors.remove(index); + if (indexInjector == null) { + return; + } + + logger.debug("[{}] closing ... (reason [{}])", index, reason); + Map tmpMap = newHashMap(indices); + indexService = tmpMap.remove(index); + indices = ImmutableMap.copyOf(tmpMap); + } + + indicesLifecycle.beforeIndexClosed(indexService); + if (delete) { + indicesLifecycle.beforeIndexDeleted(indexService); + } + IOUtils.close(Iterables.transform(pluginsService.indexServices(), new Function, Closeable>() { + @Override + public Closeable apply(Class input) { + return indexInjector.getInstance(input); + } + })); + + logger.debug("[{}] closing index service (reason [{}])", index, reason); + ((IndexService) indexService).close(reason, listener); + + logger.debug("[{}] closing index cache (reason [{}])", index, reason); + indexInjector.getInstance(IndexCache.class).close(); + logger.debug("[{}] clearing index field data (reason [{}])", index, reason); + indexInjector.getInstance(IndexFieldDataService.class).clear(); + logger.debug("[{}] closing analysis service (reason [{}])", index, reason); + indexInjector.getInstance(AnalysisService.class).close(); + logger.debug("[{}] closing index engine (reason [{}])", index, reason); + indexInjector.getInstance(IndexEngine.class).close(); + + logger.debug("[{}] closing index gateway (reason [{}])", index, reason); + indexInjector.getInstance(IndexGateway.class).close(); + logger.debug("[{}] closing mapper service (reason [{}])", index, reason); + indexInjector.getInstance(MapperService.class).close(); + logger.debug("[{}] closing index query parser service (reason [{}])", index, reason); + indexInjector.getInstance(IndexQueryParserService.class).close(); + + logger.debug("[{}] closing index service (reason [{}])", index, reason); + indexInjector.getInstance(IndexStore.class).close(); + + Injectors.close(injector); + + logger.debug("[{}] closed... (reason [{}])", index, reason); + indicesLifecycle.afterIndexClosed(indexService.index()); + if (delete) { + indicesLifecycle.afterIndexDeleted(indexService.index()); + } + } catch (IOException ex) { + throw new ElasticsearchException("failed to remove index " + index, ex); + } + } + + static class OldShardsStats extends IndicesLifecycle.Listener { + + final SearchStats searchStats = new SearchStats(); + final GetStats getStats = new GetStats(); + final IndexingStats indexingStats = new IndexingStats(); + final MergeStats mergeStats = new MergeStats(); + final RefreshStats refreshStats = new RefreshStats(); + final FlushStats flushStats = new FlushStats(); + + @Override + public synchronized void beforeIndexShardClosed(ShardId shardId, @Nullable IndexShard indexShard) { + if (indexShard != null) { + getStats.add(indexShard.getStats()); + indexingStats.add(indexShard.indexingStats(), false); + searchStats.add(indexShard.searchStats(), false); + mergeStats.add(indexShard.mergeStats()); + refreshStats.add(indexShard.refreshStats()); + flushStats.add(indexShard.flushStats()); + } + } + } /** * A listener interface that can be used to get notification once a shard or all shards @@ -125,4 +517,4 @@ public interface IndicesService extends Iterable, LifecycleCompone public void onShardCloseFailed(ShardId shardId, Throwable t); } -} +} \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/indices/InternalIndicesLifecycle.java b/src/main/java/org/elasticsearch/indices/InternalIndicesLifecycle.java index 7b255542718..5a63d2dc634 100644 --- a/src/main/java/org/elasticsearch/indices/InternalIndicesLifecycle.java +++ b/src/main/java/org/elasticsearch/indices/InternalIndicesLifecycle.java @@ -25,10 +25,10 @@ import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.IndexShardState; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import java.util.concurrent.CopyOnWriteArrayList; diff --git a/src/main/java/org/elasticsearch/indices/InternalIndicesService.java b/src/main/java/org/elasticsearch/indices/InternalIndicesService.java deleted file mode 100644 index ebf3c9b0f0c..00000000000 --- a/src/main/java/org/elasticsearch/indices/InternalIndicesService.java +++ /dev/null @@ -1,459 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.indices; - -import com.google.common.base.Function; -import com.google.common.collect.*; -import org.apache.lucene.util.IOUtils; -import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.ElasticsearchIllegalStateException; -import org.elasticsearch.action.admin.indices.stats.CommonStats; -import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags; -import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags.Flag; -import org.elasticsearch.action.admin.indices.stats.IndexShardStats; -import org.elasticsearch.action.admin.indices.stats.ShardStats; -import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.component.AbstractLifecycleComponent; -import org.elasticsearch.common.inject.*; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.util.concurrent.EsExecutors; -import org.elasticsearch.env.NodeEnvironment; -import org.elasticsearch.gateway.Gateway; -import org.elasticsearch.index.*; -import org.elasticsearch.index.aliases.IndexAliasesServiceModule; -import org.elasticsearch.index.analysis.AnalysisModule; -import org.elasticsearch.index.analysis.AnalysisService; -import org.elasticsearch.index.cache.IndexCache; -import org.elasticsearch.index.cache.IndexCacheModule; -import org.elasticsearch.index.codec.CodecModule; -import org.elasticsearch.index.engine.IndexEngine; -import org.elasticsearch.index.engine.IndexEngineModule; -import org.elasticsearch.index.fielddata.IndexFieldDataModule; -import org.elasticsearch.index.fielddata.IndexFieldDataService; -import org.elasticsearch.index.flush.FlushStats; -import org.elasticsearch.index.gateway.IndexGateway; -import org.elasticsearch.index.gateway.IndexGatewayModule; -import org.elasticsearch.index.get.GetStats; -import org.elasticsearch.index.indexing.IndexingStats; -import org.elasticsearch.index.mapper.MapperService; -import org.elasticsearch.index.mapper.MapperServiceModule; -import org.elasticsearch.index.merge.MergeStats; -import org.elasticsearch.index.query.IndexQueryParserModule; -import org.elasticsearch.index.query.IndexQueryParserService; -import org.elasticsearch.index.refresh.RefreshStats; -import org.elasticsearch.index.search.stats.SearchStats; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.service.InternalIndexService; -import org.elasticsearch.index.settings.IndexSettingsModule; -import org.elasticsearch.index.shard.IllegalIndexShardStateException; -import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; -import org.elasticsearch.index.similarity.SimilarityModule; -import org.elasticsearch.index.store.IndexStore; -import org.elasticsearch.index.store.IndexStoreModule; -import org.elasticsearch.indices.analysis.IndicesAnalysisService; -import org.elasticsearch.indices.recovery.RecoverySettings; -import org.elasticsearch.indices.store.IndicesStore; -import org.elasticsearch.plugins.IndexPluginsModule; -import org.elasticsearch.plugins.PluginsService; - -import java.io.Closeable; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import static com.google.common.collect.Maps.newHashMap; -import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; -import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; -import static org.elasticsearch.common.collect.MapBuilder.newMapBuilder; -import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder; - -/** - * - */ -public class InternalIndicesService extends AbstractLifecycleComponent implements IndicesService { - - private final InternalIndicesLifecycle indicesLifecycle; - - private final IndicesAnalysisService indicesAnalysisService; - - private final IndicesStore indicesStore; - - private final Injector injector; - - private final PluginsService pluginsService; - - private final NodeEnvironment nodeEnv; - - private final Map indicesInjectors = new HashMap<>(); - - private volatile ImmutableMap indices = ImmutableMap.of(); - - private final OldShardsStats oldShardsStats = new OldShardsStats(); - - @Inject - public InternalIndicesService(Settings settings, IndicesLifecycle indicesLifecycle, IndicesAnalysisService indicesAnalysisService, IndicesStore indicesStore, Injector injector, NodeEnvironment nodeEnv) { - super(settings); - this.indicesLifecycle = (InternalIndicesLifecycle) indicesLifecycle; - this.indicesAnalysisService = indicesAnalysisService; - this.indicesStore = indicesStore; - this.injector = injector; - - this.pluginsService = injector.getInstance(PluginsService.class); - - this.indicesLifecycle.addListener(oldShardsStats); - this.nodeEnv = nodeEnv; - } - - @Override - protected void doStart() throws ElasticsearchException { - } - - @Override - protected void doStop() throws ElasticsearchException { - ImmutableSet indices = ImmutableSet.copyOf(this.indices.keySet()); - final CountDownLatch latch = new CountDownLatch(indices.size()); - - final ExecutorService indicesStopExecutor = Executors.newFixedThreadPool(5, EsExecutors.daemonThreadFactory("indices_shutdown")); - - for (final String index : indices) { - indicesStopExecutor.execute(new Runnable() { - @Override - public void run() { - try { - removeIndex(index, "shutdown", false, new IndexCloseListener() { - @Override - public void onAllShardsClosed(Index index, List failures) { - latch.countDown(); - } - - @Override - public void onShardClosed(ShardId shardId) { - } - - @Override - public void onShardCloseFailed(ShardId shardId, Throwable t) { - } - }); - } catch (Throwable e) { - latch.countDown(); - logger.warn("failed to delete index on stop [" + index + "]", e); - } - } - }); - } - try { - if (latch.await(30, TimeUnit.SECONDS) == false) { - logger.warn("Not all shards are closed yet, waited 30sec - stopping service"); - } - } catch (InterruptedException e) { - // ignore - } finally { - indicesStopExecutor.shutdown(); - } - } - - @Override - protected void doClose() throws ElasticsearchException { - injector.getInstance(RecoverySettings.class).close(); - indicesStore.close(); - indicesAnalysisService.close(); - } - - @Override - public IndicesLifecycle indicesLifecycle() { - return this.indicesLifecycle; - } - - @Override - public NodeIndicesStats stats(boolean includePrevious) { - return stats(true, new CommonStatsFlags().all()); - } - - @Override - public NodeIndicesStats stats(boolean includePrevious, CommonStatsFlags flags) { - CommonStats oldStats = new CommonStats(flags); - - if (includePrevious) { - Flag[] setFlags = flags.getFlags(); - for (Flag flag : setFlags) { - switch (flag) { - case Get: - oldStats.get.add(oldShardsStats.getStats); - break; - case Indexing: - oldStats.indexing.add(oldShardsStats.indexingStats); - break; - case Search: - oldStats.search.add(oldShardsStats.searchStats); - break; - case Merge: - oldStats.merge.add(oldShardsStats.mergeStats); - break; - case Refresh: - oldStats.refresh.add(oldShardsStats.refreshStats); - break; - case Flush: - oldStats.flush.add(oldShardsStats.flushStats); - break; - } - } - } - - Map> statsByShard = Maps.newHashMap(); - for (IndexService indexService : indices.values()) { - for (IndexShard indexShard : indexService) { - try { - if (indexShard.routingEntry() == null) { - continue; - } - IndexShardStats indexShardStats = new IndexShardStats(indexShard.shardId(), new ShardStats[] { new ShardStats(indexShard, indexShard.routingEntry(), flags) }); - if (!statsByShard.containsKey(indexService.index())) { - statsByShard.put(indexService.index(), Lists.newArrayList(indexShardStats)); - } else { - statsByShard.get(indexService.index()).add(indexShardStats); - } - } catch (IllegalIndexShardStateException e) { - // we can safely ignore illegal state on ones that are closing for example - } - } - } - return new NodeIndicesStats(oldStats, statsByShard); - } - - /** - * Returns true if changes (adding / removing) indices, shards and so on are allowed. - */ - public boolean changesAllowed() { - // we check on stop here since we defined stop when we delete the indices - return lifecycle.started(); - } - - @Override - public UnmodifiableIterator iterator() { - return indices.values().iterator(); - } - - public boolean hasIndex(String index) { - return indices.containsKey(index); - } - - public ImmutableMap indices() { - return indices; - } - - public IndexService indexService(String index) { - return indices.get(index); - } - - @Override - public IndexService indexServiceSafe(String index) throws IndexMissingException { - IndexService indexService = indexService(index); - if (indexService == null) { - throw new IndexMissingException(new Index(index)); - } - return indexService; - } - - public synchronized IndexService createIndex(String sIndexName, Settings settings, String localNodeId) throws ElasticsearchException { - if (!lifecycle.started()) { - throw new ElasticsearchIllegalStateException("Can't create an index [" + sIndexName + "], node is closed"); - } - Index index = new Index(sIndexName); - if (indicesInjectors.containsKey(index.name())) { - throw new IndexAlreadyExistsException(index); - } - - indicesLifecycle.beforeIndexCreated(index); - - logger.debug("creating Index [{}], shards [{}]/[{}]", sIndexName, settings.get(SETTING_NUMBER_OF_SHARDS), settings.get(SETTING_NUMBER_OF_REPLICAS)); - - Settings indexSettings = settingsBuilder() - .put(this.settings) - .put(settings) - .classLoader(settings.getClassLoader()) - .build(); - - ModulesBuilder modules = new ModulesBuilder(); - modules.add(new IndexNameModule(index)); - modules.add(new LocalNodeIdModule(localNodeId)); - modules.add(new IndexSettingsModule(index, indexSettings)); - modules.add(new IndexPluginsModule(indexSettings, pluginsService)); - modules.add(new IndexStoreModule(indexSettings)); - modules.add(new IndexEngineModule(indexSettings)); - modules.add(new AnalysisModule(indexSettings, indicesAnalysisService)); - modules.add(new SimilarityModule(indexSettings)); - modules.add(new IndexCacheModule(indexSettings)); - modules.add(new IndexFieldDataModule(indexSettings)); - modules.add(new CodecModule(indexSettings)); - modules.add(new MapperServiceModule()); - modules.add(new IndexQueryParserModule(indexSettings)); - modules.add(new IndexAliasesServiceModule()); - modules.add(new IndexGatewayModule(indexSettings, injector.getInstance(Gateway.class))); - modules.add(new IndexModule(indexSettings)); - - Injector indexInjector; - try { - indexInjector = modules.createChildInjector(injector); - } catch (CreationException e) { - throw new IndexCreationException(index, Injectors.getFirstErrorFailure(e)); - } catch (Throwable e) { - throw new IndexCreationException(index, e); - } - - indicesInjectors.put(index.name(), indexInjector); - - IndexService indexService = indexInjector.getInstance(IndexService.class); - - indicesLifecycle.afterIndexCreated(indexService); - - indices = newMapBuilder(indices).put(index.name(), indexService).immutableMap(); - - return indexService; - } - - @Override - public void removeIndex(String index, String reason) throws ElasticsearchException { - removeIndex(index, reason, false, null); - } - - @Override - public void deleteIndex(String index, String reason) throws ElasticsearchException { - removeIndex(index, reason, true, new IndicesService.IndexCloseListener() { - - @Override - public void onAllShardsClosed(Index index, List failures) { - try { - nodeEnv.deleteIndexDirectorySafe(index); - logger.debug("deleted index [{}] from filesystem - failures {}", index, failures); - } catch (Exception e) { - for (Throwable t : failures) { - e.addSuppressed(t); - } - logger.debug("failed to deleted index [{}] from filesystem", e, index); - // ignore - still some shards locked here - } - } - - @Override - public void onShardClosed(ShardId shardId) { - try { - // this is called under the shard lock - we can safely delete it - IOUtils.rm(nodeEnv.shardPaths(shardId)); - logger.debug("deleted shard [{}] from filesystem", shardId); - } catch (IOException e) { - logger.warn("Can't delete shard {} ", e, shardId); - } - } - - @Override - public void onShardCloseFailed(ShardId shardId, Throwable t) { - } - }); - } - - private void removeIndex(String index, String reason, boolean delete, @Nullable IndexCloseListener listener) throws ElasticsearchException { - try { - final IndexService indexService; - final Injector indexInjector; - synchronized (this) { - indexInjector = indicesInjectors.remove(index); - if (indexInjector == null) { - return; - } - - logger.debug("[{}] closing ... (reason [{}])", index, reason); - Map tmpMap = newHashMap(indices); - indexService = tmpMap.remove(index); - indices = ImmutableMap.copyOf(tmpMap); - } - - indicesLifecycle.beforeIndexClosed(indexService); - if (delete) { - indicesLifecycle.beforeIndexDeleted(indexService); - } - IOUtils.close(Iterables.transform(pluginsService.indexServices(), new Function, Closeable>() { - @Override - public Closeable apply(Class input) { - return indexInjector.getInstance(input); - } - })); - - logger.debug("[{}] closing index service (reason [{}])", index, reason); - ((InternalIndexService) indexService).close(reason, listener); - - logger.debug("[{}] closing index cache (reason [{}])", index, reason); - indexInjector.getInstance(IndexCache.class).close(); - logger.debug("[{}] clearing index field data (reason [{}])", index, reason); - indexInjector.getInstance(IndexFieldDataService.class).clear(); - logger.debug("[{}] closing analysis service (reason [{}])", index, reason); - indexInjector.getInstance(AnalysisService.class).close(); - logger.debug("[{}] closing index engine (reason [{}])", index, reason); - indexInjector.getInstance(IndexEngine.class).close(); - - logger.debug("[{}] closing index gateway (reason [{}])", index, reason); - indexInjector.getInstance(IndexGateway.class).close(); - logger.debug("[{}] closing mapper service (reason [{}])", index, reason); - indexInjector.getInstance(MapperService.class).close(); - logger.debug("[{}] closing index query parser service (reason [{}])", index, reason); - indexInjector.getInstance(IndexQueryParserService.class).close(); - - logger.debug("[{}] closing index service (reason [{}])", index, reason); - indexInjector.getInstance(IndexStore.class).close(); - - Injectors.close(injector); - - logger.debug("[{}] closed... (reason [{}])", index, reason); - indicesLifecycle.afterIndexClosed(indexService.index()); - if (delete) { - indicesLifecycle.afterIndexDeleted(indexService.index()); - } - } catch (IOException ex) { - throw new ElasticsearchException("failed to remove index " + index, ex); - } - } - - static class OldShardsStats extends IndicesLifecycle.Listener { - - final SearchStats searchStats = new SearchStats(); - final GetStats getStats = new GetStats(); - final IndexingStats indexingStats = new IndexingStats(); - final MergeStats mergeStats = new MergeStats(); - final RefreshStats refreshStats = new RefreshStats(); - final FlushStats flushStats = new FlushStats(); - - @Override - public synchronized void beforeIndexShardClosed(ShardId shardId, @Nullable IndexShard indexShard) { - if (indexShard != null) { - getStats.add(indexShard.getStats()); - indexingStats.add(indexShard.indexingStats(), false); - searchStats.add(indexShard.searchStats(), false); - mergeStats.add(indexShard.mergeStats()); - refreshStats.add(indexShard.refreshStats()); - flushStats.add(indexShard.flushStats()); - } - } - } -} \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/indices/NodeIndicesStats.java b/src/main/java/org/elasticsearch/indices/NodeIndicesStats.java index f790eb36345..d06f922d523 100644 --- a/src/main/java/org/elasticsearch/indices/NodeIndicesStats.java +++ b/src/main/java/org/elasticsearch/indices/NodeIndicesStats.java @@ -45,8 +45,6 @@ import org.elasticsearch.index.percolator.stats.PercolateStats; import org.elasticsearch.index.refresh.RefreshStats; import org.elasticsearch.index.search.stats.SearchStats; import org.elasticsearch.index.shard.DocsStats; -import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; import org.elasticsearch.index.store.StoreStats; import org.elasticsearch.index.suggest.stats.SuggestStats; import org.elasticsearch.search.suggest.completion.CompletionStats; diff --git a/src/main/java/org/elasticsearch/indices/cache/query/IndicesQueryCache.java b/src/main/java/org/elasticsearch/indices/cache/query/IndicesQueryCache.java index 18f20be3fc8..0f506c79814 100644 --- a/src/main/java/org/elasticsearch/indices/cache/query/IndicesQueryCache.java +++ b/src/main/java/org/elasticsearch/indices/cache/query/IndicesQueryCache.java @@ -44,7 +44,7 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; import org.elasticsearch.index.shard.IndexShardState; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.search.SearchShardTarget; import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.search.internal.ShardSearchRequest; diff --git a/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java b/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java index b405983e96b..f5d09cbe54d 100644 --- a/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java +++ b/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java @@ -47,7 +47,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; import org.elasticsearch.env.NodeEnvironment; -import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexShardAlreadyExistsException; import org.elasticsearch.index.IndexShardMissingException; import org.elasticsearch.index.aliases.IndexAlias; @@ -57,19 +56,17 @@ import org.elasticsearch.index.gateway.IndexShardGatewayRecoveryException; import org.elasticsearch.index.gateway.IndexShardGatewayService; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.MapperService; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.settings.IndexSettingsService; import org.elasticsearch.index.shard.IndexShardState; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; -import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.recovery.RecoveryFailedException; import org.elasticsearch.indices.recovery.RecoveryState; import org.elasticsearch.indices.recovery.RecoveryTarget; import org.elasticsearch.threadpool.ThreadPool; -import java.io.IOException; import java.util.*; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicLong; @@ -552,7 +549,7 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent openIndexOutputs = ConcurrentCollections.newConcurrentMap(); private final Store.LegacyChecksums legacyChecksums = new Store.LegacyChecksums(); - public RecoveryStatus(InternalIndexShard indexShard, DiscoveryNode sourceNode, RecoveryState state, RecoveryTarget.RecoveryListener listener) { + public RecoveryStatus(IndexShard indexShard, DiscoveryNode sourceNode, RecoveryState state, RecoveryTarget.RecoveryListener listener) { super("recovery_status"); this.recoveryId = idGenerator.incrementAndGet(); this.listener = listener; @@ -97,7 +97,7 @@ public class RecoveryStatus extends AbstractRefCounted { return shardId; } - public InternalIndexShard indexShard() { + public IndexShard indexShard() { ensureRefCount(); return indexShard; } diff --git a/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java b/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java index f588450741e..5bfaf8346bb 100644 --- a/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java +++ b/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java @@ -40,8 +40,7 @@ import org.elasticsearch.index.shard.IllegalIndexShardStateException; import org.elasticsearch.index.shard.IndexShardClosedException; import org.elasticsearch.index.shard.IndexShardNotStartedException; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; -import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.store.Store; import org.elasticsearch.index.store.StoreFileMetaData; import org.elasticsearch.index.translog.Translog; @@ -124,7 +123,7 @@ public class RecoveryTarget extends AbstractComponent { } } - public void startRecovery(final InternalIndexShard indexShard, final RecoveryState.Type recoveryType, final DiscoveryNode sourceNode, final RecoveryListener listener) { + public void startRecovery(final IndexShard indexShard, final RecoveryState.Type recoveryType, final DiscoveryNode sourceNode, final RecoveryListener listener) { try { indexShard.recovering("from " + sourceNode); } catch (IllegalIndexShardStateException e) { diff --git a/src/main/java/org/elasticsearch/indices/recovery/ShardRecoveryHandler.java b/src/main/java/org/elasticsearch/indices/recovery/ShardRecoveryHandler.java index 051eb2c32ff..ad32499a8ba 100644 --- a/src/main/java/org/elasticsearch/indices/recovery/ShardRecoveryHandler.java +++ b/src/main/java/org/elasticsearch/indices/recovery/ShardRecoveryHandler.java @@ -21,7 +21,6 @@ package org.elasticsearch.indices.recovery; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import com.google.common.collect.Sets; import org.apache.lucene.index.CorruptIndexException; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput; @@ -46,11 +45,11 @@ import org.elasticsearch.common.util.concurrent.ConcurrentCollections; import org.elasticsearch.index.deletionpolicy.SnapshotIndexCommit; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.IllegalIndexShardStateException; import org.elasticsearch.index.shard.IndexShardClosedException; import org.elasticsearch.index.shard.IndexShardState; -import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.store.Store; import org.elasticsearch.index.store.StoreFileMetaData; import org.elasticsearch.index.translog.Translog; @@ -75,7 +74,7 @@ public final class ShardRecoveryHandler implements Engine.RecoveryHandler { private final ESLogger logger; // Shard that is going to be recovered (the "source") - private final InternalIndexShard shard; + private final IndexShard shard; private final String indexName; private final int shardId; // Request containing source and target node information @@ -101,7 +100,7 @@ public final class ShardRecoveryHandler implements Engine.RecoveryHandler { }; - public ShardRecoveryHandler(final InternalIndexShard shard, final StartRecoveryRequest request, final RecoverySettings recoverySettings, + public ShardRecoveryHandler(final IndexShard shard, final StartRecoveryRequest request, final RecoverySettings recoverySettings, final TransportService transportService, final TimeValue internalActionTimeout, final TimeValue internalActionLongTimeout, final ClusterService clusterService, final IndicesService indicesService, final MappingUpdatedAction mappingUpdatedAction, final ESLogger logger) { diff --git a/src/main/java/org/elasticsearch/indices/store/IndicesStore.java b/src/main/java/org/elasticsearch/indices/store/IndicesStore.java index e83da209267..6903ea93fbc 100644 --- a/src/main/java/org/elasticsearch/indices/store/IndicesStore.java +++ b/src/main/java/org/elasticsearch/indices/store/IndicesStore.java @@ -37,16 +37,15 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeUnit; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.env.NodeEnvironment; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.IndexShardState; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.node.settings.NodeSettingsService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.*; -import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.util.ArrayList; diff --git a/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java b/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java index 45089dc29f3..82c17fa7c1e 100644 --- a/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java +++ b/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java @@ -40,16 +40,15 @@ import org.elasticsearch.common.io.stream.Streamable; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.env.NodeEnvironment; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.store.Store; import org.elasticsearch.index.store.StoreFileMetaData; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; -import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.util.*; @@ -146,7 +145,7 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesOperatio private StoreFilesMetaData listStoreMetaData(ShardId shardId) throws IOException { IndexService indexService = indicesService.indexService(shardId.index().name()); if (indexService != null) { - InternalIndexShard indexShard = (InternalIndexShard) indexService.shard(shardId.id()); + IndexShard indexShard = indexService.shard(shardId.id()); if (indexShard != null) { final Store store = indexShard.store(); store.incRef(); diff --git a/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java b/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java index 2a4df54b154..36a1387ab43 100644 --- a/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java +++ b/src/main/java/org/elasticsearch/indices/ttl/IndicesTTLService.java @@ -46,9 +46,9 @@ import org.elasticsearch.index.mapper.FieldMappers; import org.elasticsearch.index.mapper.Uid; import org.elasticsearch.index.mapper.internal.TTLFieldMapper; import org.elasticsearch.index.mapper.internal.UidFieldMapper; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.IndexShardState; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.node.settings.NodeSettingsService; diff --git a/src/main/java/org/elasticsearch/indices/warmer/IndicesWarmer.java b/src/main/java/org/elasticsearch/indices/warmer/IndicesWarmer.java index db9b1c216b5..559c3768ec6 100644 --- a/src/main/java/org/elasticsearch/indices/warmer/IndicesWarmer.java +++ b/src/main/java/org/elasticsearch/indices/warmer/IndicesWarmer.java @@ -23,7 +23,7 @@ import org.apache.lucene.index.IndexReader; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.threadpool.ThreadPool; /** diff --git a/src/main/java/org/elasticsearch/indices/warmer/InternalIndicesWarmer.java b/src/main/java/org/elasticsearch/indices/warmer/InternalIndicesWarmer.java index df3ecb295d3..ec8d0b9d507 100644 --- a/src/main/java/org/elasticsearch/indices/warmer/InternalIndicesWarmer.java +++ b/src/main/java/org/elasticsearch/indices/warmer/InternalIndicesWarmer.java @@ -26,8 +26,8 @@ import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.threadpool.ThreadPool; diff --git a/src/main/java/org/elasticsearch/percolator/PercolateContext.java b/src/main/java/org/elasticsearch/percolator/PercolateContext.java index a9c15170def..7fc3f76fb2a 100644 --- a/src/main/java/org/elasticsearch/percolator/PercolateContext.java +++ b/src/main/java/org/elasticsearch/percolator/PercolateContext.java @@ -43,8 +43,8 @@ import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.query.IndexQueryParserService; import org.elasticsearch.index.query.ParsedFilter; import org.elasticsearch.index.query.ParsedQuery; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.similarity.SimilarityService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.search.Scroll; diff --git a/src/main/java/org/elasticsearch/percolator/PercolatorService.java b/src/main/java/org/elasticsearch/percolator/PercolatorService.java index 9eb63b2ce8d..5e5e2b98308 100644 --- a/src/main/java/org/elasticsearch/percolator/PercolatorService.java +++ b/src/main/java/org/elasticsearch/percolator/PercolatorService.java @@ -73,8 +73,8 @@ import org.elasticsearch.index.mapper.internal.IdFieldMapper; import org.elasticsearch.index.percolator.stats.ShardPercolateService; import org.elasticsearch.index.query.ParsedQuery; import org.elasticsearch.index.search.nested.NonNestedDocsFilter; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.percolator.QueryCollector.Count; import org.elasticsearch.percolator.QueryCollector.Match; diff --git a/src/main/java/org/elasticsearch/search/SearchService.java b/src/main/java/org/elasticsearch/search/SearchService.java index 8f90b3f2e91..9da011a2d7e 100644 --- a/src/main/java/org/elasticsearch/search/SearchService.java +++ b/src/main/java/org/elasticsearch/search/SearchService.java @@ -62,8 +62,8 @@ import org.elasticsearch.index.mapper.FieldMapper.Loading; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.query.TemplateQueryParser; import org.elasticsearch.index.search.stats.StatsGroupsParseElement; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesLifecycle; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.cache.query.IndicesQueryCache; diff --git a/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java b/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java index d8763ff92d5..ca4b02eec51 100644 --- a/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java +++ b/src/main/java/org/elasticsearch/search/internal/DefaultSearchContext.java @@ -49,8 +49,8 @@ import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.query.IndexQueryParserService; import org.elasticsearch.index.query.ParsedFilter; import org.elasticsearch.index.query.ParsedQuery; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.similarity.SimilarityService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.search.Scroll; diff --git a/src/main/java/org/elasticsearch/search/internal/FilteredSearchContext.java b/src/main/java/org/elasticsearch/search/internal/FilteredSearchContext.java index 2e9b4ba7375..cd0a7c93954 100644 --- a/src/main/java/org/elasticsearch/search/internal/FilteredSearchContext.java +++ b/src/main/java/org/elasticsearch/search/internal/FilteredSearchContext.java @@ -37,7 +37,7 @@ import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.query.IndexQueryParserService; import org.elasticsearch.index.query.ParsedFilter; import org.elasticsearch.index.query.ParsedQuery; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.similarity.SimilarityService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.search.Scroll; diff --git a/src/main/java/org/elasticsearch/search/internal/SearchContext.java b/src/main/java/org/elasticsearch/search/internal/SearchContext.java index 6892b5b8d6d..7a7b53e6a92 100644 --- a/src/main/java/org/elasticsearch/search/internal/SearchContext.java +++ b/src/main/java/org/elasticsearch/search/internal/SearchContext.java @@ -43,7 +43,7 @@ import org.elasticsearch.index.query.IndexQueryParserService; import org.elasticsearch.index.query.ParsedFilter; import org.elasticsearch.index.query.ParsedQuery; import org.elasticsearch.index.query.QueryParseContext; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.similarity.SimilarityService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.search.Scroll; diff --git a/src/test/java/org/elasticsearch/common/lucene/docset/DocIdSetsTests.java b/src/test/java/org/elasticsearch/common/lucene/docset/DocIdSetsTests.java index f3f2ae348cb..5eb2f28da7d 100644 --- a/src/test/java/org/elasticsearch/common/lucene/docset/DocIdSetsTests.java +++ b/src/test/java/org/elasticsearch/common/lucene/docset/DocIdSetsTests.java @@ -36,7 +36,7 @@ import org.elasticsearch.index.engine.Engine.Searcher; import org.elasticsearch.index.query.FilterBuilder; import org.elasticsearch.index.query.FilterBuilders; import org.elasticsearch.index.query.TermFilterBuilder; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.test.ElasticsearchSingleNodeTest; public class DocIdSetsTests extends ElasticsearchSingleNodeTest { diff --git a/src/test/java/org/elasticsearch/index/aliases/IndexAliasesServiceTests.java b/src/test/java/org/elasticsearch/index/aliases/IndexAliasesServiceTests.java index a87b19facee..2e1fc9e8da7 100644 --- a/src/test/java/org/elasticsearch/index/aliases/IndexAliasesServiceTests.java +++ b/src/test/java/org/elasticsearch/index/aliases/IndexAliasesServiceTests.java @@ -26,7 +26,7 @@ import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.query.FilterBuilder; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.indices.InvalidAliasNameException; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/index/codec/CodecTests.java b/src/test/java/org/elasticsearch/index/codec/CodecTests.java index fd984fe8df6..9445355eac6 100644 --- a/src/test/java/org/elasticsearch/index/codec/CodecTests.java +++ b/src/test/java/org/elasticsearch/index/codec/CodecTests.java @@ -53,7 +53,7 @@ import org.elasticsearch.index.codec.postingsformat.*; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.internal.UidFieldMapper; import org.elasticsearch.index.mapper.internal.VersionFieldMapper; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.test.ElasticsearchSingleNodeLuceneTestCase; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/index/engine/internal/InternalEngineSettingsTest.java b/src/test/java/org/elasticsearch/index/engine/internal/InternalEngineSettingsTest.java index 20ead5fb313..74b040f6ab5 100644 --- a/src/test/java/org/elasticsearch/index/engine/internal/InternalEngineSettingsTest.java +++ b/src/test/java/org/elasticsearch/index/engine/internal/InternalEngineSettingsTest.java @@ -19,7 +19,7 @@ package org.elasticsearch.index.engine.internal; import org.elasticsearch.common.settings.ImmutableSettings; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import static org.hamcrest.Matchers.is; diff --git a/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataTests.java b/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataTests.java index ece2826a26e..3a40961cead 100644 --- a/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataTests.java +++ b/src/test/java/org/elasticsearch/index/fielddata/AbstractFieldDataTests.java @@ -26,7 +26,6 @@ import org.apache.lucene.index.*; import org.apache.lucene.search.Filter; import org.apache.lucene.store.RAMDirectory; import org.apache.lucene.util.LuceneTestCase.SuppressCodecs; -import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.mapper.ContentPath; @@ -34,7 +33,7 @@ import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.Mapper.BuilderContext; import org.elasticsearch.index.mapper.MapperBuilders; import org.elasticsearch.index.mapper.MapperService; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.junit.After; diff --git a/src/test/java/org/elasticsearch/index/fielddata/IndexFieldDataServiceTests.java b/src/test/java/org/elasticsearch/index/fielddata/IndexFieldDataServiceTests.java index 4f496630873..fc3987f88ec 100644 --- a/src/test/java/org/elasticsearch/index/fielddata/IndexFieldDataServiceTests.java +++ b/src/test/java/org/elasticsearch/index/fielddata/IndexFieldDataServiceTests.java @@ -33,7 +33,7 @@ import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.Mapper.BuilderContext; import org.elasticsearch.index.mapper.MapperBuilders; import org.elasticsearch.index.mapper.core.*; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import java.util.Arrays; diff --git a/src/test/java/org/elasticsearch/index/mapper/boost/BoostMappingIntegrationTests.java b/src/test/java/org/elasticsearch/index/mapper/boost/BoostMappingIntegrationTests.java index f163b3c2b58..826fa481449 100644 --- a/src/test/java/org/elasticsearch/index/mapper/boost/BoostMappingIntegrationTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/boost/BoostMappingIntegrationTests.java @@ -21,10 +21,7 @@ package org.elasticsearch.index.mapper.boost; import org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse; import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.index.mapper.DocumentMapper; -import org.elasticsearch.index.service.IndexService; import org.elasticsearch.test.ElasticsearchIntegrationTest; -import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.junit.Test; import java.util.LinkedHashMap; diff --git a/src/test/java/org/elasticsearch/index/mapper/boost/BoostMappingTests.java b/src/test/java/org/elasticsearch/index/mapper/boost/BoostMappingTests.java index 78ee24c3941..e1f159fa5bd 100644 --- a/src/test/java/org/elasticsearch/index/mapper/boost/BoostMappingTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/boost/BoostMappingTests.java @@ -21,13 +21,11 @@ package org.elasticsearch.index.mapper.boost; import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexableField; -import org.elasticsearch.common.compress.CompressedString; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.mapper.internal.BoostFieldMapper; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.indices.IndicesService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperTests.java b/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperTests.java index ae108a9ad54..fe2f096ad98 100644 --- a/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/copyto/CopyToMapperTests.java @@ -30,7 +30,7 @@ import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.ParseContext.Document; import org.elasticsearch.index.mapper.core.LongFieldMapper; import org.elasticsearch.index.mapper.core.StringFieldMapper; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/index/mapper/dynamic/DynamicMappingTests.java b/src/test/java/org/elasticsearch/index/mapper/dynamic/DynamicMappingTests.java index 5af8f9823e5..b201f32e45c 100644 --- a/src/test/java/org/elasticsearch/index/mapper/dynamic/DynamicMappingTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/dynamic/DynamicMappingTests.java @@ -23,7 +23,7 @@ import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.FieldMappers; import org.elasticsearch.index.mapper.ParsedDocument; import org.elasticsearch.index.mapper.StrictDynamicMappingException; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldTests.java b/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldTests.java index 519767accb8..97c8b389562 100644 --- a/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldTests.java @@ -33,7 +33,7 @@ import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.ParseContext.Document; import org.elasticsearch.index.mapper.core.*; import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/index/mapper/null_value/NullValueTests.java b/src/test/java/org/elasticsearch/index/mapper/null_value/NullValueTests.java index 7fc0b1adefc..34cdc5f601d 100644 --- a/src/test/java/org/elasticsearch/index/mapper/null_value/NullValueTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/null_value/NullValueTests.java @@ -23,7 +23,7 @@ package org.elasticsearch.index.mapper.null_value; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.MapperParsingException; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java b/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java index e8b742e8c84..756e044116c 100644 --- a/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java @@ -26,7 +26,7 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.ParseContext.Document; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/index/mapper/source/DefaultSourceMappingTests.java b/src/test/java/org/elasticsearch/index/mapper/source/DefaultSourceMappingTests.java index cc3f1cf97ef..b8b0a91af38 100644 --- a/src/test/java/org/elasticsearch/index/mapper/source/DefaultSourceMappingTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/source/DefaultSourceMappingTests.java @@ -28,7 +28,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.index.mapper.*; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java b/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java index ca7b1ac30c3..e015a71012c 100644 --- a/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/string/SimpleStringMappingTests.java @@ -20,7 +20,6 @@ package org.elasticsearch.index.mapper.string; import com.google.common.collect.ImmutableMap; -import org.apache.lucene.index.FieldInfo; import org.apache.lucene.index.DocValuesType; import org.apache.lucene.index.IndexOptions; import org.apache.lucene.index.IndexableField; @@ -36,7 +35,7 @@ import org.elasticsearch.index.mapper.DocumentMapper.MergeResult; import org.elasticsearch.index.mapper.Mapper.BuilderContext; import org.elasticsearch.index.mapper.ParseContext.Document; import org.elasticsearch.index.mapper.core.StringFieldMapper; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/index/mapper/ttl/TTLMappingTests.java b/src/test/java/org/elasticsearch/index/mapper/ttl/TTLMappingTests.java index d60be66668c..0c2f9d88eba 100644 --- a/src/test/java/org/elasticsearch/index/mapper/ttl/TTLMappingTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/ttl/TTLMappingTests.java @@ -28,7 +28,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.*; import org.elasticsearch.index.mapper.internal.TTLFieldMapper; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingTests.java b/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingTests.java index 33a6fdb60a3..687f768e742 100644 --- a/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/update/UpdateMappingTests.java @@ -26,7 +26,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.MapperService; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/index/query/IndexQueryParserFilterCachingTests.java b/src/test/java/org/elasticsearch/index/query/IndexQueryParserFilterCachingTests.java index 47996ef51fb..78366d6ac1d 100644 --- a/src/test/java/org/elasticsearch/index/query/IndexQueryParserFilterCachingTests.java +++ b/src/test/java/org/elasticsearch/index/query/IndexQueryParserFilterCachingTests.java @@ -33,7 +33,7 @@ import org.elasticsearch.common.lucene.search.XBooleanFilter; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.mapper.MapperService; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.elasticsearch.test.TestSearchContext; diff --git a/src/test/java/org/elasticsearch/index/query/IndexQueryParserFilterDateRangeFormatTests.java b/src/test/java/org/elasticsearch/index/query/IndexQueryParserFilterDateRangeFormatTests.java index 8f96ad2b421..c006c958479 100644 --- a/src/test/java/org/elasticsearch/index/query/IndexQueryParserFilterDateRangeFormatTests.java +++ b/src/test/java/org/elasticsearch/index/query/IndexQueryParserFilterDateRangeFormatTests.java @@ -26,7 +26,7 @@ import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.compress.CompressedString; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.index.mapper.MapperService; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.elasticsearch.test.TestSearchContext; diff --git a/src/test/java/org/elasticsearch/index/query/IndexQueryParserFilterDateRangeTimezoneTests.java b/src/test/java/org/elasticsearch/index/query/IndexQueryParserFilterDateRangeTimezoneTests.java index 95164c3c06e..e1e92f886ad 100644 --- a/src/test/java/org/elasticsearch/index/query/IndexQueryParserFilterDateRangeTimezoneTests.java +++ b/src/test/java/org/elasticsearch/index/query/IndexQueryParserFilterDateRangeTimezoneTests.java @@ -26,7 +26,7 @@ import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.compress.CompressedString; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.index.mapper.MapperService; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.elasticsearch.test.TestSearchContext; diff --git a/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java b/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java index 624a02e6a86..539910833dc 100644 --- a/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java +++ b/src/test/java/org/elasticsearch/index/query/SimpleIndexQueryParserTests.java @@ -61,7 +61,7 @@ import org.elasticsearch.index.search.geo.GeoDistanceFilter; import org.elasticsearch.index.search.geo.GeoPolygonFilter; import org.elasticsearch.index.search.geo.InMemoryGeoBoundingBoxFilter; import org.elasticsearch.index.search.morelikethis.MoreLikeThisFetchService; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.hamcrest.Matchers; diff --git a/src/test/java/org/elasticsearch/index/search/FieldDataTermsFilterTests.java b/src/test/java/org/elasticsearch/index/search/FieldDataTermsFilterTests.java index b873b760fc8..f48f39bbae7 100644 --- a/src/test/java/org/elasticsearch/index/search/FieldDataTermsFilterTests.java +++ b/src/test/java/org/elasticsearch/index/search/FieldDataTermsFilterTests.java @@ -28,7 +28,6 @@ import org.apache.lucene.index.*; import org.apache.lucene.store.RAMDirectory; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.FixedBitSet; -import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.fielddata.IndexFieldData; @@ -43,7 +42,7 @@ import org.elasticsearch.index.mapper.core.NumberFieldMapper; import org.elasticsearch.index.mapper.core.StringFieldMapper; import org.elasticsearch.index.query.IndexQueryParserService; import org.elasticsearch.index.query.QueryParseContext; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.junit.After; diff --git a/src/test/java/org/elasticsearch/index/search/child/AbstractChildTests.java b/src/test/java/org/elasticsearch/index/search/child/AbstractChildTests.java index 64dc1849d20..7d36e10826e 100644 --- a/src/test/java/org/elasticsearch/index/search/child/AbstractChildTests.java +++ b/src/test/java/org/elasticsearch/index/search/child/AbstractChildTests.java @@ -33,7 +33,7 @@ import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.internal.UidFieldMapper; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryParseContext; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.test.ElasticsearchSingleNodeLuceneTestCase; import org.hamcrest.Description; diff --git a/src/test/java/org/elasticsearch/index/store/CorruptedFileTest.java b/src/test/java/org/elasticsearch/index/store/CorruptedFileTest.java index 2e11cf471fc..360fd810f85 100644 --- a/src/test/java/org/elasticsearch/index/store/CorruptedFileTest.java +++ b/src/test/java/org/elasticsearch/index/store/CorruptedFileTest.java @@ -56,8 +56,7 @@ import org.elasticsearch.index.merge.policy.MergePolicyModule; import org.elasticsearch.index.shard.IndexShardException; import org.elasticsearch.index.shard.IndexShardState; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; -import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.translog.TranslogService; import org.elasticsearch.indices.IndicesLifecycle; import org.elasticsearch.indices.IndicesService; @@ -187,7 +186,7 @@ public class CorruptedFileTest extends ElasticsearchIntegrationTest { @Override public void afterIndexShardClosed(ShardId sid, @Nullable IndexShard indexShard) { if (indexShard != null) { - Store store = ((InternalIndexShard) indexShard).store(); + Store store = ((IndexShard) indexShard).store(); store.incRef(); try { if (!Lucene.indexExists(store.directory()) && indexShard.state() == IndexShardState.STARTED) { diff --git a/src/test/java/org/elasticsearch/indices/IndicesLifecycleListenerSingleNodeTests.java b/src/test/java/org/elasticsearch/indices/IndicesLifecycleListenerSingleNodeTests.java index 0b5d0f14c7b..86e68cd3f1e 100644 --- a/src/test/java/org/elasticsearch/indices/IndicesLifecycleListenerSingleNodeTests.java +++ b/src/test/java/org/elasticsearch/indices/IndicesLifecycleListenerSingleNodeTests.java @@ -18,35 +18,15 @@ */ package org.elasticsearch.indices; -import com.google.common.base.Predicate; -import com.google.common.collect.Maps; -import org.elasticsearch.cluster.routing.ShardRouting; -import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.Strings; import org.elasticsearch.index.Index; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.IndexShardState; -import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; -import org.elasticsearch.test.ElasticsearchIntegrationTest; +import org.elasticsearch.index.IndexService; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.junit.Test; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentMap; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; -import static org.elasticsearch.cluster.routing.allocation.decider.DisableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_DISABLE_ALLOCATION; -import static org.elasticsearch.common.settings.ImmutableSettings.builder; -import static org.elasticsearch.index.shard.IndexShardState.*; -import static org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope; -import static org.elasticsearch.test.ElasticsearchIntegrationTest.Scope; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; public class IndicesLifecycleListenerSingleNodeTests extends ElasticsearchSingleNodeTest { diff --git a/src/test/java/org/elasticsearch/indices/IndicesLifecycleListenerTests.java b/src/test/java/org/elasticsearch/indices/IndicesLifecycleListenerTests.java index 89b1a6bef70..da072a1dd8a 100644 --- a/src/test/java/org/elasticsearch/indices/IndicesLifecycleListenerTests.java +++ b/src/test/java/org/elasticsearch/indices/IndicesLifecycleListenerTests.java @@ -24,7 +24,7 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; import org.elasticsearch.index.shard.IndexShardState; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/indices/leaks/IndicesLeaksTests.java b/src/test/java/org/elasticsearch/indices/leaks/IndicesLeaksTests.java index 418837bfee4..3238b381730 100644 --- a/src/test/java/org/elasticsearch/indices/leaks/IndicesLeaksTests.java +++ b/src/test/java/org/elasticsearch/indices/leaks/IndicesLeaksTests.java @@ -23,8 +23,8 @@ import org.elasticsearch.common.inject.Injector; import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.elasticsearch.test.ElasticsearchIntegrationTest.ClusterScope; diff --git a/src/test/java/org/elasticsearch/indices/memory/IndexingMemoryControllerTests.java b/src/test/java/org/elasticsearch/indices/memory/IndexingMemoryControllerTests.java index 71bd07419c3..341bb9b5a93 100644 --- a/src/test/java/org/elasticsearch/indices/memory/IndexingMemoryControllerTests.java +++ b/src/test/java/org/elasticsearch/indices/memory/IndexingMemoryControllerTests.java @@ -27,7 +27,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.engine.internal.InternalEngineHolder; -import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.junit.Test; @@ -45,13 +45,13 @@ public class IndexingMemoryControllerTests extends ElasticsearchIntegrationTest ensureGreen(); - final InternalIndexShard shard1 = (InternalIndexShard) internalCluster().getInstance(IndicesService.class).indexService("test1").shard(0); + final IndexShard shard1 = internalCluster().getInstance(IndicesService.class).indexService("test1").shard(0); prepareCreate("test2").setSettings(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1, IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0).get(); ensureGreen(); - final InternalIndexShard shard2 = (InternalIndexShard) internalCluster().getInstance(IndicesService.class).indexService("test2").shard(0); + final IndexShard shard2 = internalCluster().getInstance(IndicesService.class).indexService("test2").shard(0); final long expected1ShardSize = internalCluster().getInstance(IndexingMemoryController.class).indexingBufferSize().bytes(); final long expected2ShardsSize = expected1ShardSize / 2; @@ -95,7 +95,7 @@ public class IndexingMemoryControllerTests extends ElasticsearchIntegrationTest ensureGreen(); - final InternalIndexShard shard1 = (InternalIndexShard) internalCluster().getInstance(IndicesService.class).indexService("test1").shard(0); + final IndexShard shard1 = internalCluster().getInstance(IndicesService.class).indexService("test1").shard(0); boolean success = awaitBusy(new Predicate() { @Override public boolean apply(Object input) { diff --git a/src/test/java/org/elasticsearch/indices/recovery/RecoveryStatusTests.java b/src/test/java/org/elasticsearch/indices/recovery/RecoveryStatusTests.java index b5e651c9567..84206f4ef77 100644 --- a/src/test/java/org/elasticsearch/indices/recovery/RecoveryStatusTests.java +++ b/src/test/java/org/elasticsearch/indices/recovery/RecoveryStatusTests.java @@ -23,8 +23,8 @@ import org.apache.lucene.store.IndexOutput; import org.elasticsearch.Version; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.transport.LocalTransportAddress; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.store.StoreFileMetaData; import org.elasticsearch.test.ElasticsearchSingleNodeTest; @@ -40,7 +40,7 @@ public class RecoveryStatusTests extends ElasticsearchSingleNodeTest { IndexService service = createIndex("foo"); RecoveryState state = new RecoveryState(); - InternalIndexShard indexShard = (InternalIndexShard) service.shard(0); + IndexShard indexShard = service.shard(0); DiscoveryNode node = new DiscoveryNode("foo", new LocalTransportAddress("bar"), Version.CURRENT); RecoveryStatus status = new RecoveryStatus(indexShard, node, state, new RecoveryTarget.RecoveryListener() { @Override diff --git a/src/test/java/org/elasticsearch/indices/store/SimpleDistributorTests.java b/src/test/java/org/elasticsearch/indices/store/SimpleDistributorTests.java index 8fe07363c12..9fe7a037850 100644 --- a/src/test/java/org/elasticsearch/indices/store/SimpleDistributorTests.java +++ b/src/test/java/org/elasticsearch/indices/store/SimpleDistributorTests.java @@ -21,13 +21,12 @@ package org.elasticsearch.indices.store; import org.apache.lucene.store.Directory; import org.elasticsearch.env.NodeEnvironment; -import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.store.IndexStoreModule; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.junit.Test; -import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.util.Locale; @@ -153,7 +152,7 @@ public class SimpleDistributorTests extends ElasticsearchIntegrationTest { Set nodes = internalCluster().nodesInclude("test"); assertThat(nodes.isEmpty(), equalTo(false)); IndicesService indicesService = internalCluster().getInstance(IndicesService.class, nodes.iterator().next()); - InternalIndexShard indexShard = (InternalIndexShard) (indicesService.indexService(index).shardSafe(shardId)); + IndexShard indexShard = indicesService.indexService(index).shardSafe(shardId); return indexShard.store().directory(); } } diff --git a/src/test/java/org/elasticsearch/recovery/RelocationTests.java b/src/test/java/org/elasticsearch/recovery/RelocationTests.java index dc3444c662a..4168877a508 100644 --- a/src/test/java/org/elasticsearch/recovery/RelocationTests.java +++ b/src/test/java/org/elasticsearch/recovery/RelocationTests.java @@ -51,7 +51,7 @@ import org.elasticsearch.discovery.DiscoveryService; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.index.shard.IndexShardState; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesLifecycle; import org.elasticsearch.indices.recovery.RecoveryFileChunkRequest; import org.elasticsearch.indices.recovery.RecoverySettings; diff --git a/src/test/java/org/elasticsearch/search/child/ParentFieldLoadingTest.java b/src/test/java/org/elasticsearch/search/child/ParentFieldLoadingTest.java index 1e3d2fafe0a..203466e4326 100644 --- a/src/test/java/org/elasticsearch/search/child/ParentFieldLoadingTest.java +++ b/src/test/java/org/elasticsearch/search/child/ParentFieldLoadingTest.java @@ -31,13 +31,11 @@ import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.merge.policy.MergePolicyModule; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.elasticsearch.test.index.merge.NoMergePolicyProvider; -import org.elasticsearch.test.junit.annotations.TestLogging; -import org.elasticsearch.update.UpdateTests; import org.junit.Test; import java.io.IOException; @@ -54,7 +52,7 @@ public class ParentFieldLoadingTest extends ElasticsearchIntegrationTest { private final Settings indexSettings = ImmutableSettings.builder() .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0) - .put(InternalIndexShard.INDEX_REFRESH_INTERVAL, -1) + .put(IndexShard.INDEX_REFRESH_INTERVAL, -1) // We never want merges in this test to ensure we have two segments for the last validation .put(MergePolicyModule.MERGE_POLICY_TYPE_KEY, NoMergePolicyProvider.class) .build(); diff --git a/src/test/java/org/elasticsearch/search/sort/SortParserTests.java b/src/test/java/org/elasticsearch/search/sort/SortParserTests.java index 614492c7d57..1d9bf3c78c2 100644 --- a/src/test/java/org/elasticsearch/search/sort/SortParserTests.java +++ b/src/test/java/org/elasticsearch/search/sort/SortParserTests.java @@ -26,7 +26,7 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.elasticsearch.test.TestSearchContext; import org.junit.Test; diff --git a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java index 6a836664532..68743dd56e1 100644 --- a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java +++ b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java @@ -96,7 +96,7 @@ import org.elasticsearch.index.mapper.internal.*; import org.elasticsearch.index.merge.policy.*; import org.elasticsearch.index.merge.scheduler.ConcurrentMergeSchedulerProvider; import org.elasticsearch.index.merge.scheduler.MergeSchedulerModule; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.store.StoreModule; import org.elasticsearch.index.translog.TranslogService; import org.elasticsearch.index.translog.fs.FsTranslog; diff --git a/src/test/java/org/elasticsearch/test/ElasticsearchSingleNodeLuceneTestCase.java b/src/test/java/org/elasticsearch/test/ElasticsearchSingleNodeLuceneTestCase.java index 7fa53aac238..ee5325b90e4 100644 --- a/src/test/java/org/elasticsearch/test/ElasticsearchSingleNodeLuceneTestCase.java +++ b/src/test/java/org/elasticsearch/test/ElasticsearchSingleNodeLuceneTestCase.java @@ -20,7 +20,7 @@ package org.elasticsearch.test; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.search.internal.SearchContext; import org.junit.After; import org.junit.Ignore; diff --git a/src/test/java/org/elasticsearch/test/ElasticsearchSingleNodeTest.java b/src/test/java/org/elasticsearch/test/ElasticsearchSingleNodeTest.java index faf7b22cb03..6348959e938 100644 --- a/src/test/java/org/elasticsearch/test/ElasticsearchSingleNodeTest.java +++ b/src/test/java/org/elasticsearch/test/ElasticsearchSingleNodeTest.java @@ -37,8 +37,8 @@ import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.engine.internal.InternalEngine; import org.elasticsearch.index.engine.internal.InternalEngineHolder; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.node.Node; import org.elasticsearch.node.NodeBuilder; @@ -194,7 +194,7 @@ public abstract class ElasticsearchSingleNodeTest extends ElasticsearchTestCase } protected static InternalEngine engine(IndexService service) { - return ((InternalEngineHolder) ((InternalIndexShard) service.shard(0)).engine()).engineSafe(); + return ((InternalEngineHolder) ((IndexShard) service.shard(0)).engine()).engineSafe(); } /** diff --git a/src/test/java/org/elasticsearch/test/InternalTestCluster.java b/src/test/java/org/elasticsearch/test/InternalTestCluster.java index a2acb7ae66b..26f65b0b827 100644 --- a/src/test/java/org/elasticsearch/test/InternalTestCluster.java +++ b/src/test/java/org/elasticsearch/test/InternalTestCluster.java @@ -30,8 +30,6 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; -import org.apache.lucene.store.Lock; -import org.apache.lucene.store.NativeFSLockFactory; import org.apache.lucene.util.AbstractRandomizedTest; import org.apache.lucene.util.IOUtils; import org.elasticsearch.ElasticsearchException; @@ -76,7 +74,7 @@ import org.elasticsearch.index.cache.filter.FilterCacheModule; import org.elasticsearch.index.cache.filter.none.NoneFilterCache; import org.elasticsearch.index.cache.filter.weighted.WeightedFilterCache; import org.elasticsearch.index.engine.IndexEngineModule; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.breaker.CircuitBreakerService; @@ -102,24 +100,16 @@ import org.elasticsearch.transport.netty.NettyTransport; import org.junit.Assert; import java.io.Closeable; -import java.io.File; import java.io.IOException; import java.net.InetSocketAddress; -import java.nio.file.FileVisitResult; -import java.nio.file.FileVisitor; -import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.nio.file.attribute.BasicFileAttributes; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; -import static com.carrotsearch.randomizedtesting.RandomizedTest.between; -import static com.carrotsearch.randomizedtesting.RandomizedTest.frequently; -import static com.carrotsearch.randomizedtesting.RandomizedTest.randomBoolean; import static junit.framework.Assert.fail; import static org.apache.lucene.util.LuceneTestCase.TEST_NIGHTLY; import static org.apache.lucene.util.LuceneTestCase.rarely; diff --git a/src/test/java/org/elasticsearch/test/TestSearchContext.java b/src/test/java/org/elasticsearch/test/TestSearchContext.java index d340331765e..55fc2ccb1aa 100644 --- a/src/test/java/org/elasticsearch/test/TestSearchContext.java +++ b/src/test/java/org/elasticsearch/test/TestSearchContext.java @@ -37,8 +37,8 @@ import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.query.IndexQueryParserService; import org.elasticsearch.index.query.ParsedFilter; import org.elasticsearch.index.query.ParsedQuery; -import org.elasticsearch.index.service.IndexService; -import org.elasticsearch.index.shard.service.IndexShard; +import org.elasticsearch.index.IndexService; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.similarity.SimilarityService; import org.elasticsearch.script.ScriptService; import org.elasticsearch.search.Scroll; diff --git a/src/test/java/org/elasticsearch/test/store/MockFSDirectoryService.java b/src/test/java/org/elasticsearch/test/store/MockFSDirectoryService.java index 691f5b4f4e8..bb2a262c278 100644 --- a/src/test/java/org/elasticsearch/test/store/MockFSDirectoryService.java +++ b/src/test/java/org/elasticsearch/test/store/MockFSDirectoryService.java @@ -26,7 +26,6 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.store.LockFactory; import org.apache.lucene.store.StoreRateLimiting; import org.apache.lucene.util.AbstractRandomizedTest; -import org.elasticsearch.action.admin.indices.flush.FlushRequest; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.stream.BytesStreamOutput; @@ -37,8 +36,7 @@ import org.elasticsearch.index.settings.IndexSettings; import org.elasticsearch.index.shard.IndexShardException; import org.elasticsearch.index.shard.IndexShardState; import org.elasticsearch.index.shard.ShardId; -import org.elasticsearch.index.shard.service.IndexShard; -import org.elasticsearch.index.shard.service.InternalIndexShard; +import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.store.IndexStore; import org.elasticsearch.index.store.Store; import org.elasticsearch.index.store.distributor.Distributor; @@ -47,7 +45,6 @@ import org.elasticsearch.indices.IndicesLifecycle; import org.elasticsearch.indices.IndicesService; import org.elasticsearch.test.ElasticsearchIntegrationTest; -import java.io.File; import java.io.IOException; import java.io.PrintStream; import java.nio.file.Path; @@ -88,7 +85,7 @@ public class MockFSDirectoryService extends FsDirectoryService { // When the the internal engine closes we do a rollback, which removes uncommitted segments // By doing a commit flush we perform a Lucene commit, but don't clear the translog, // so that even in tests where don't flush we can check the integrity of the Lucene index - ((InternalIndexShard)indexShard).engine().flush(Engine.FlushType.COMMIT, false, true); // Keep translog for tests that rely on replaying it + ((IndexShard)indexShard).engine().flush(Engine.FlushType.COMMIT, false, true); // Keep translog for tests that rely on replaying it logger.info("flush finished in beforeIndexShardClosed"); } } @@ -98,7 +95,7 @@ public class MockFSDirectoryService extends FsDirectoryService { public void afterIndexShardClosed(ShardId sid, @Nullable IndexShard indexShard) { if (shardId.equals(sid) && indexShard != null && canRun) { assert indexShard.state() == IndexShardState.CLOSED : "Current state must be closed"; - checkIndex(((InternalIndexShard) indexShard).store(), sid); + checkIndex(((IndexShard) indexShard).store(), sid); } service.indicesLifecycle().removeListener(this); } diff --git a/src/test/java/org/elasticsearch/test/store/MockFSIndexStore.java b/src/test/java/org/elasticsearch/test/store/MockFSIndexStore.java index ad09f6a10d2..662918e0aea 100644 --- a/src/test/java/org/elasticsearch/test/store/MockFSIndexStore.java +++ b/src/test/java/org/elasticsearch/test/store/MockFSIndexStore.java @@ -23,7 +23,7 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.index.Index; -import org.elasticsearch.index.service.IndexService; +import org.elasticsearch.index.IndexService; import org.elasticsearch.index.store.DirectoryService; import org.elasticsearch.index.store.support.AbstractIndexStore; import org.elasticsearch.indices.store.IndicesStore;