org.elasticsearch.index.shard.service
Class InternalIndexShard

java.lang.Object
  extended by org.elasticsearch.index.shard.AbstractIndexShardComponent
      extended by org.elasticsearch.index.shard.service.InternalIndexShard
All Implemented Interfaces:
CloseableComponent, IndexShardComponent, IndexShard

@ThreadSafe
public class InternalIndexShard
extends AbstractIndexShardComponent
implements IndexShard


Field Summary
 
Fields inherited from class org.elasticsearch.index.shard.AbstractIndexShardComponent
componentSettings, indexSettings, logger, shardId
 
Constructor Summary
InternalIndexShard(ShardId shardId, Settings indexSettings, Store store, Engine engine, Translog translog, ThreadPool threadPool, MapperService mapperService, IndexQueryParserService queryParserService, IndexCache indexCache)
           
 
Method Summary
 EngineException[] bulk(Engine.Bulk bulk)
           
 void close()
           
 long count(float minScore, byte[] querySource, int querySourceOffset, int querySourceLength, java.lang.String queryParserName, java.lang.String... types)
           
 long count(float minScore, byte[] querySource, java.lang.String queryParserName, java.lang.String... types)
           
 ParsedDocument create(Engine.Create create)
           
 void delete(Engine.Delete delete)
           
 void delete(org.apache.lucene.index.Term uid)
           
 void deleteByQuery(byte[] querySource, java.lang.String queryParserName, java.lang.String... types)
           
 Engine engine()
           
 ByteSizeValue estimateFlushableMemorySize()
          Returns the estimated flushable memory size.
 void flush(Engine.Flush flush)
           
 byte[] get(java.lang.String type, java.lang.String id)
           
 boolean ignoreRecoveryAttempt()
          Returns true if this shard can ignore a recovery attempt made to it (since the already doing/done it)
 ParsedDocument index(Engine.Index index)
           
 void optimize(Engine.Optimize optimize)
           
 RecoveryStatus peerRecoveryStatus()
          The peer recovery status if this shard recovered from a peer shard.
 void performRecoveryFinalization(boolean withFlush)
           
 void performRecoveryFinalization(boolean withFlush, RecoveryStatus peerRecoveryStatus)
           
 void performRecoveryOperation(Translog.Operation operation)
           
 void performRecoveryPrepareForTranslog()
          After the store has been recovered, we need to start the engine in order to apply operations
 Engine.Create prepareCreate(SourceToParse source)
           
 Engine.Delete prepareDelete(java.lang.String type, java.lang.String id)
           
 Engine.Index prepareIndex(SourceToParse source)
           
 void readAllowed()
           
 void recover(Engine.RecoveryHandler recoveryHandler)
           
 IndexShardState recovering()
          Marks the shard as recovering, fails with exception is recovering is not allowed to be set.
 void refresh(Engine.Refresh refresh)
           
 InternalIndexShard relocated()
           
 ShardRouting routingEntry()
           
 InternalIndexShard routingEntry(ShardRouting shardRouting)
           
 Engine.Searcher searcher()
           
<T> T
snapshot(Engine.SnapshotHandler<T> snapshotHandler)
           
 InternalIndexShard start()
           
 IndexShardState state()
           
 Store store()
           
 Translog translog()
           
 void writeAllowed()
           
 
Methods inherited from class org.elasticsearch.index.shard.AbstractIndexShardComponent
indexSettings, managementGroupName, nodeName, shardId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.elasticsearch.index.shard.IndexShardComponent
indexSettings, shardId
 

Constructor Detail

InternalIndexShard

@Inject
public InternalIndexShard(ShardId shardId,
                                 @IndexSettings
                                 Settings indexSettings,
                                 Store store,
                                 Engine engine,
                                 Translog translog,
                                 ThreadPool threadPool,
                                 MapperService mapperService,
                                 IndexQueryParserService queryParserService,
                                 IndexCache indexCache)
Method Detail

store

public Store store()

engine

public Engine engine()

translog

public Translog translog()

routingEntry

public ShardRouting routingEntry()
Specified by:
routingEntry in interface IndexShard

routingEntry

public InternalIndexShard routingEntry(ShardRouting shardRouting)

recovering

public IndexShardState recovering()
                           throws IndexShardStartedException,
                                  IndexShardRelocatedException,
                                  IndexShardRecoveringException,
                                  IndexShardClosedException
Marks the shard as recovering, fails with exception is recovering is not allowed to be set.

Throws:
IndexShardStartedException
IndexShardRelocatedException
IndexShardRecoveringException
IndexShardClosedException

relocated

public InternalIndexShard relocated()
                             throws IndexShardNotStartedException
Throws:
IndexShardNotStartedException

start

public InternalIndexShard start()
                         throws IndexShardStartedException,
                                IndexShardRelocatedException,
                                IndexShardClosedException
Throws:
IndexShardStartedException
IndexShardRelocatedException
IndexShardClosedException

state

public IndexShardState state()
Specified by:
state in interface IndexShard

estimateFlushableMemorySize

public ByteSizeValue estimateFlushableMemorySize()
                                          throws ElasticSearchException
Returns the estimated flushable memory size. Returns null if not available.

Specified by:
estimateFlushableMemorySize in interface IndexShard
Throws:
ElasticSearchException

prepareCreate

public Engine.Create prepareCreate(SourceToParse source)
                            throws ElasticSearchException
Specified by:
prepareCreate in interface IndexShard
Throws:
ElasticSearchException

create

public ParsedDocument create(Engine.Create create)
                      throws ElasticSearchException
Specified by:
create in interface IndexShard
Throws:
ElasticSearchException

prepareIndex

public Engine.Index prepareIndex(SourceToParse source)
                          throws ElasticSearchException
Specified by:
prepareIndex in interface IndexShard
Throws:
ElasticSearchException

index

public ParsedDocument index(Engine.Index index)
                     throws ElasticSearchException
Specified by:
index in interface IndexShard
Throws:
ElasticSearchException

prepareDelete

public Engine.Delete prepareDelete(java.lang.String type,
                                   java.lang.String id)
                            throws ElasticSearchException
Specified by:
prepareDelete in interface IndexShard
Throws:
ElasticSearchException

delete

public void delete(org.apache.lucene.index.Term uid)
Specified by:
delete in interface IndexShard

delete

public void delete(Engine.Delete delete)
            throws ElasticSearchException
Specified by:
delete in interface IndexShard
Throws:
ElasticSearchException

bulk

public EngineException[] bulk(Engine.Bulk bulk)
                       throws ElasticSearchException
Specified by:
bulk in interface IndexShard
Throws:
ElasticSearchException

deleteByQuery

public void deleteByQuery(byte[] querySource,
                          @Nullable
                          java.lang.String queryParserName,
                          java.lang.String... types)
                   throws ElasticSearchException
Specified by:
deleteByQuery in interface IndexShard
Throws:
ElasticSearchException

get

public byte[] get(java.lang.String type,
                  java.lang.String id)
           throws ElasticSearchException
Specified by:
get in interface IndexShard
Throws:
ElasticSearchException

count

public long count(float minScore,
                  byte[] querySource,
                  @Nullable
                  java.lang.String queryParserName,
                  java.lang.String... types)
           throws ElasticSearchException
Specified by:
count in interface IndexShard
Throws:
ElasticSearchException

count

public long count(float minScore,
                  byte[] querySource,
                  int querySourceOffset,
                  int querySourceLength,
                  @Nullable
                  java.lang.String queryParserName,
                  java.lang.String... types)
           throws ElasticSearchException
Specified by:
count in interface IndexShard
Throws:
ElasticSearchException

refresh

public void refresh(Engine.Refresh refresh)
             throws ElasticSearchException
Specified by:
refresh in interface IndexShard
Throws:
ElasticSearchException

flush

public void flush(Engine.Flush flush)
           throws ElasticSearchException
Specified by:
flush in interface IndexShard
Throws:
ElasticSearchException

optimize

public void optimize(Engine.Optimize optimize)
              throws ElasticSearchException
Specified by:
optimize in interface IndexShard
Throws:
ElasticSearchException

snapshot

public <T> T snapshot(Engine.SnapshotHandler<T> snapshotHandler)
           throws EngineException
Specified by:
snapshot in interface IndexShard
Throws:
EngineException

recover

public void recover(Engine.RecoveryHandler recoveryHandler)
             throws EngineException
Specified by:
recover in interface IndexShard
Throws:
EngineException

searcher

public Engine.Searcher searcher()
Specified by:
searcher in interface IndexShard

close

public void close()
Specified by:
close in interface CloseableComponent

performRecoveryPrepareForTranslog

public void performRecoveryPrepareForTranslog()
                                       throws ElasticSearchException
After the store has been recovered, we need to start the engine in order to apply operations

Throws:
ElasticSearchException

peerRecoveryStatus

public RecoveryStatus peerRecoveryStatus()
The peer recovery status if this shard recovered from a peer shard.


performRecoveryFinalization

public void performRecoveryFinalization(boolean withFlush,
                                        RecoveryStatus peerRecoveryStatus)
                                 throws ElasticSearchException
Throws:
ElasticSearchException

performRecoveryFinalization

public void performRecoveryFinalization(boolean withFlush)
                                 throws ElasticSearchException
Throws:
ElasticSearchException

performRecoveryOperation

public void performRecoveryOperation(Translog.Operation operation)
                              throws ElasticSearchException
Throws:
ElasticSearchException

ignoreRecoveryAttempt

public boolean ignoreRecoveryAttempt()
Returns true if this shard can ignore a recovery attempt made to it (since the already doing/done it)

Specified by:
ignoreRecoveryAttempt in interface IndexShard

readAllowed

public void readAllowed()
                 throws IllegalIndexShardStateException
Throws:
IllegalIndexShardStateException

writeAllowed

public void writeAllowed()
                  throws IllegalIndexShardStateException
Throws:
IllegalIndexShardStateException