more index and shard lifecycle annotations, in any case, one should extend the respective base classes

This commit is contained in:
kimchy 2010-04-07 17:25:35 +03:00
parent 5e4f7c77a2
commit 7ed9435a3a
31 changed files with 22 additions and 153 deletions

View File

@ -28,9 +28,8 @@ import org.slf4j.Logger;
import static org.elasticsearch.index.IndexServiceManagement.*;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
@IndexLifecycle
public abstract class AbstractIndexComponent implements IndexComponent {
protected final Logger logger;

View File

@ -20,9 +20,8 @@
package org.elasticsearch.index;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
@IndexLifecycle
public interface IndexComponent {
Index index();

View File

@ -1,41 +0,0 @@
/*
* Licensed to Elastic Search and Shay Banon under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Elastic Search 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;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
/**
* A simple annotation that marks a component to be bounded to a single index
* lifecycle.
* <p/>
* <p>Note, currently only acts as a marker interface for readability.
*
* @author kimchy (Shay Banon)
*/
@Target({TYPE, ANNOTATION_TYPE})
@Retention(RUNTIME)
@Documented
public @interface IndexLifecycle {
}

View File

@ -24,7 +24,6 @@ import com.google.inject.Inject;
import org.apache.lucene.analysis.Analyzer;
import org.elasticsearch.index.AbstractIndexComponent;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexLifecycle;
import org.elasticsearch.index.settings.IndexSettings;
import org.elasticsearch.util.Nullable;
import org.elasticsearch.util.component.CloseableComponent;
@ -38,7 +37,6 @@ import static com.google.common.collect.Maps.*;
/**
* @author kimchy (Shay Banon)
*/
@IndexLifecycle
public class AnalysisService extends AbstractIndexComponent implements CloseableComponent {
private final ImmutableMap<String, AnalyzerProvider> analyzerProviders;

View File

@ -21,14 +21,12 @@ package org.elasticsearch.index.cache.filter;
import com.google.inject.AbstractModule;
import com.google.inject.Scopes;
import org.elasticsearch.index.IndexLifecycle;
import org.elasticsearch.index.cache.filter.soft.SoftFilterCache;
import org.elasticsearch.util.settings.Settings;
/**
* @author kimchy (Shay Banon)
*/
@IndexLifecycle
public class FilterCacheModule extends AbstractModule {
public static final class FilterCacheSettings {

View File

@ -22,15 +22,13 @@ package org.elasticsearch.index.deletionpolicy;
import com.google.inject.AbstractModule;
import com.google.inject.name.Names;
import org.apache.lucene.index.IndexDeletionPolicy;
import org.elasticsearch.index.shard.IndexShardLifecycle;
import org.elasticsearch.util.settings.Settings;
import static org.elasticsearch.index.deletionpolicy.DeletionPolicyModule.DeletionPolicySettings.*;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
@IndexShardLifecycle
public class DeletionPolicyModule extends AbstractModule {
public static class DeletionPolicySettings {

View File

@ -24,7 +24,6 @@ import org.apache.lucene.index.IndexCommit;
import org.apache.lucene.index.IndexDeletionPolicy;
import org.elasticsearch.index.settings.IndexSettings;
import org.elasticsearch.index.shard.AbstractIndexShardComponent;
import org.elasticsearch.index.shard.IndexShardLifecycle;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.util.settings.Settings;
@ -32,9 +31,8 @@ import java.io.IOException;
import java.util.List;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
@IndexShardLifecycle
public class KeepLastNDeletionPolicy extends AbstractIndexShardComponent implements IndexDeletionPolicy {
private final int numToKeep;

View File

@ -24,7 +24,6 @@ import org.apache.lucene.index.IndexCommit;
import org.apache.lucene.index.IndexDeletionPolicy;
import org.elasticsearch.index.settings.IndexSettings;
import org.elasticsearch.index.shard.AbstractIndexShardComponent;
import org.elasticsearch.index.shard.IndexShardLifecycle;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.util.settings.Settings;
@ -36,7 +35,6 @@ import java.util.List;
* all prior commits after a new commit is done. This is
* the default deletion policy.
*/
@IndexShardLifecycle
public class KeepOnlyLastDeletionPolicy extends AbstractIndexShardComponent implements IndexDeletionPolicy {
@Inject public KeepOnlyLastDeletionPolicy(ShardId shardId, @IndexSettings Settings indexSettings) {

View File

@ -25,7 +25,6 @@ import org.apache.lucene.index.IndexCommit;
import org.apache.lucene.index.IndexDeletionPolicy;
import org.elasticsearch.index.shard.AbstractIndexShardComponent;
import org.elasticsearch.index.shard.IndexShardComponent;
import org.elasticsearch.index.shard.IndexShardLifecycle;
import java.io.IOException;
import java.util.ArrayList;
@ -39,9 +38,8 @@ import java.util.concurrent.ConcurrentMap;
* and if the deletion policy is used with all open index writers (JVM level) then the snapshot
* state will not be deleted until it will be released.
*
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
@IndexShardLifecycle
public class SnapshotDeletionPolicy extends AbstractIndexShardComponent implements IndexDeletionPolicy {
private final IndexDeletionPolicy primary;

View File

@ -28,7 +28,6 @@ import org.apache.lucene.search.Query;
import org.elasticsearch.ElasticSearchException;
import org.elasticsearch.index.deletionpolicy.SnapshotIndexCommit;
import org.elasticsearch.index.shard.IndexShardComponent;
import org.elasticsearch.index.shard.IndexShardLifecycle;
import org.elasticsearch.index.translog.Translog;
import org.elasticsearch.util.Nullable;
import org.elasticsearch.util.SizeValue;
@ -37,10 +36,9 @@ import org.elasticsearch.util.concurrent.ThreadSafe;
import org.elasticsearch.util.lease.Releasable;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
@ThreadSafe
@IndexShardLifecycle
public interface Engine extends IndexShardComponent, CloseableComponent {
/**

View File

@ -33,7 +33,6 @@ import org.elasticsearch.index.merge.policy.MergePolicyProvider;
import org.elasticsearch.index.merge.scheduler.MergeSchedulerProvider;
import org.elasticsearch.index.settings.IndexSettings;
import org.elasticsearch.index.shard.AbstractIndexShardComponent;
import org.elasticsearch.index.shard.IndexShardLifecycle;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.similarity.SimilarityService;
import org.elasticsearch.index.store.Store;
@ -57,9 +56,8 @@ import static org.elasticsearch.util.concurrent.resource.AcquirableResourceFacto
import static org.elasticsearch.util.lucene.Lucene.*;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
@IndexShardLifecycle
public class RobinEngine extends AbstractIndexShardComponent implements Engine, ScheduledRefreshableEngine {
private final SizeValue ramBufferSize;

View File

@ -28,7 +28,6 @@ import org.elasticsearch.env.Environment;
import org.elasticsearch.env.FailedToResolveConfigException;
import org.elasticsearch.index.AbstractIndexComponent;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexLifecycle;
import org.elasticsearch.index.analysis.AnalysisService;
import org.elasticsearch.index.mapper.json.JsonDocumentMapperParser;
import org.elasticsearch.index.settings.IndexSettings;
@ -49,7 +48,6 @@ import static org.elasticsearch.util.MapBuilder.*;
/**
* @author kimchy (Shay Banon)
*/
@IndexLifecycle
@ThreadSafe
public class MapperService extends AbstractIndexComponent implements Iterable<DocumentMapper> {

View File

@ -24,16 +24,14 @@ import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.LogByteSizeMergePolicy;
import org.apache.lucene.index.LogMergePolicy;
import org.elasticsearch.index.shard.AbstractIndexShardComponent;
import org.elasticsearch.index.shard.IndexShardLifecycle;
import org.elasticsearch.index.store.Store;
import org.elasticsearch.util.Preconditions;
import org.elasticsearch.util.SizeUnit;
import org.elasticsearch.util.SizeValue;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
@IndexShardLifecycle
public class BalancedSegmentMergePolicyProvider extends AbstractIndexShardComponent implements MergePolicyProvider<LogByteSizeMergePolicy> {
private final SizeValue minMergeSize;

View File

@ -23,16 +23,14 @@ import com.google.inject.Inject;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.LogByteSizeMergePolicy;
import org.elasticsearch.index.shard.AbstractIndexShardComponent;
import org.elasticsearch.index.shard.IndexShardLifecycle;
import org.elasticsearch.index.store.Store;
import org.elasticsearch.util.Preconditions;
import org.elasticsearch.util.SizeUnit;
import org.elasticsearch.util.SizeValue;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
@IndexShardLifecycle
public class LogByteSizeMergePolicyProvider extends AbstractIndexShardComponent implements MergePolicyProvider<LogByteSizeMergePolicy> {
private final SizeValue minMergeSize;

View File

@ -23,14 +23,12 @@ import com.google.inject.Inject;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.LogDocMergePolicy;
import org.elasticsearch.index.shard.AbstractIndexShardComponent;
import org.elasticsearch.index.shard.IndexShardLifecycle;
import org.elasticsearch.index.store.Store;
import org.elasticsearch.util.Preconditions;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
@IndexShardLifecycle
public class LogDocMergePolicyProvider extends AbstractIndexShardComponent implements MergePolicyProvider<LogDocMergePolicy> {
private final int minMergeDocs;

View File

@ -20,7 +20,6 @@
package org.elasticsearch.index.merge.policy;
import com.google.inject.BindingAnnotation;
import org.elasticsearch.index.shard.IndexShardLifecycle;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
@ -38,6 +37,5 @@ import static java.lang.annotation.RetentionPolicy.*;
@Target({FIELD, PARAMETER})
@Retention(RUNTIME)
@Documented
@IndexShardLifecycle
public @interface MergeFactor {
}

View File

@ -21,13 +21,11 @@ package org.elasticsearch.index.merge.policy;
import com.google.inject.AbstractModule;
import org.apache.lucene.index.LogMergePolicy;
import org.elasticsearch.index.shard.IndexShardLifecycle;
import org.elasticsearch.util.settings.Settings;
/**
* @author kimchy (Shay Banon)
*/
@IndexShardLifecycle
public class MergePolicyModule extends AbstractModule {
private final Settings settings;

View File

@ -24,14 +24,12 @@ import org.apache.lucene.index.ConcurrentMergeScheduler;
import org.apache.lucene.index.MergeScheduler;
import org.elasticsearch.index.settings.IndexSettings;
import org.elasticsearch.index.shard.AbstractIndexShardComponent;
import org.elasticsearch.index.shard.IndexShardLifecycle;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.util.settings.Settings;
/**
* @author kimchy (Shay Banon)
*/
@IndexShardLifecycle
public class ConcurrentMergeSchedulerProvider extends AbstractIndexShardComponent implements MergeSchedulerProvider {
private final int maxThreadCount;

View File

@ -20,15 +20,13 @@
package org.elasticsearch.index.merge.scheduler;
import com.google.inject.AbstractModule;
import org.elasticsearch.index.shard.IndexShardLifecycle;
import org.elasticsearch.util.settings.Settings;
import static org.elasticsearch.index.merge.scheduler.MergeSchedulerModule.MergeSchedulerSettings.*;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
@IndexShardLifecycle
public class MergeSchedulerModule extends AbstractModule {
public static class MergeSchedulerSettings {

View File

@ -24,14 +24,12 @@ import org.apache.lucene.index.MergeScheduler;
import org.apache.lucene.index.SerialMergeScheduler;
import org.elasticsearch.index.settings.IndexSettings;
import org.elasticsearch.index.shard.AbstractIndexShardComponent;
import org.elasticsearch.index.shard.IndexShardLifecycle;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.util.settings.Settings;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
@IndexShardLifecycle
public class SerialMergeSchedulerProvider extends AbstractIndexShardComponent implements MergeSchedulerProvider {
@Inject public SerialMergeSchedulerProvider(ShardId shardId, @IndexSettings Settings indexSettings) {

View File

@ -22,7 +22,6 @@ package org.elasticsearch.index.service;
import com.google.inject.Injector;
import org.elasticsearch.ElasticSearchException;
import org.elasticsearch.index.IndexComponent;
import org.elasticsearch.index.IndexLifecycle;
import org.elasticsearch.index.IndexShardMissingException;
import org.elasticsearch.index.cache.IndexCache;
import org.elasticsearch.index.mapper.MapperService;
@ -37,7 +36,6 @@ import java.util.Set;
/**
* @author kimchy (Shay Banon)
*/
@IndexLifecycle
public interface IndexService extends IndexComponent, Iterable<IndexShard>, CloseableIndexComponent {
Injector injector();

View File

@ -24,7 +24,10 @@ import com.google.common.collect.UnmodifiableIterator;
import com.google.inject.Inject;
import com.google.inject.Injector;
import org.elasticsearch.ElasticSearchException;
import org.elasticsearch.index.*;
import org.elasticsearch.index.AbstractIndexComponent;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexShardAlreadyExistsException;
import org.elasticsearch.index.IndexShardMissingException;
import org.elasticsearch.index.cache.IndexCache;
import org.elasticsearch.index.deletionpolicy.DeletionPolicyModule;
import org.elasticsearch.index.engine.Engine;
@ -64,7 +67,6 @@ import static org.elasticsearch.util.MapBuilder.*;
/**
* @author kimchy (Shay Banon)
*/
@IndexLifecycle
public class InternalIndexService extends AbstractIndexComponent implements IndexService {
private final Injector injector;

View File

@ -20,7 +20,6 @@
package org.elasticsearch.index.settings;
import com.google.inject.BindingAnnotation;
import org.elasticsearch.index.IndexLifecycle;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
@ -37,6 +36,5 @@ import static java.lang.annotation.RetentionPolicy.*;
@Target({FIELD, PARAMETER})
@Retention(RUNTIME)
@Documented
@IndexLifecycle
public @interface IndexSettings {
}

View File

@ -20,13 +20,11 @@
package org.elasticsearch.index.settings;
import com.google.inject.AbstractModule;
import org.elasticsearch.index.IndexLifecycle;
import org.elasticsearch.util.settings.Settings;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
@IndexLifecycle
public class IndexSettingsModule extends AbstractModule {
private final Settings settings;

View File

@ -24,7 +24,6 @@ import org.elasticsearch.util.settings.Settings;
/**
* @author kimchy (Shay Banon)
*/
@IndexShardLifecycle
public interface IndexShardComponent {
ShardId shardId();

View File

@ -1,41 +0,0 @@
/*
* Licensed to Elastic Search and Shay Banon under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Elastic Search 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;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
/**
* A simple annotation that marks a component to be bounded to a single index shard
* lifecycle.
* <p/>
* <p>Note, currently only acts as a marker interface for readability.
*
* @author kimchy (Shay Banon)
*/
@Target({TYPE, ANNOTATION_TYPE})
@Retention(RUNTIME)
@Documented
public @interface IndexShardLifecycle {
}

View File

@ -25,9 +25,8 @@ import org.elasticsearch.index.shard.service.IndexShard;
import org.elasticsearch.index.shard.service.InternalIndexShard;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
@IndexShardLifecycle
public class IndexShardModule extends AbstractModule {
private final ShardId shardId;

View File

@ -26,7 +26,6 @@ import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.engine.EngineException;
import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.index.shard.IndexShardComponent;
import org.elasticsearch.index.shard.IndexShardLifecycle;
import org.elasticsearch.index.shard.IndexShardState;
import org.elasticsearch.util.Nullable;
import org.elasticsearch.util.SizeValue;
@ -34,9 +33,8 @@ import org.elasticsearch.util.component.CloseableComponent;
import org.elasticsearch.util.concurrent.ThreadSafe;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
@IndexShardLifecycle
@ThreadSafe
public interface IndexShard extends IndexShardComponent, CloseableComponent {

View File

@ -57,9 +57,8 @@ import java.io.IOException;
import java.util.concurrent.ScheduledFuture;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
@IndexShardLifecycle
@ThreadSafe
public class InternalIndexShard extends AbstractIndexShardComponent implements IndexShard {

View File

@ -21,15 +21,13 @@ package org.elasticsearch.index.store;
import org.apache.lucene.store.Directory;
import org.elasticsearch.index.shard.IndexShardComponent;
import org.elasticsearch.index.shard.IndexShardLifecycle;
import org.elasticsearch.util.SizeValue;
import java.io.IOException;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
@IndexShardLifecycle
public interface Store<T extends Directory> extends IndexShardComponent {
/**

View File

@ -26,7 +26,6 @@ import org.apache.lucene.store.MMapDirectory;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.LocalNodeId;
import org.elasticsearch.index.settings.IndexSettings;
import org.elasticsearch.index.shard.IndexShardLifecycle;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.store.support.ForceSyncDirectory;
import org.elasticsearch.util.lucene.store.SwitchDirectory;
@ -38,9 +37,8 @@ import java.io.IOException;
import static org.elasticsearch.index.store.fs.FsStores.*;
/**
* @author kimchy (Shay Banon)
* @author kimchy (shay.banon)
*/
@IndexShardLifecycle
public class MmapFsStore extends AbstractFsStore<Directory> {
private final boolean syncToDisk;