public class Store extends AbstractIndexShardComponent implements CloseableIndexComponent, Closeable, RefCounted
store.incRef(); try { // use the store... } finally { store.decRef(); }
Modifier and Type | Class and Description |
---|---|
static class |
Store.LegacyChecksums |
static class |
Store.MetadataSnapshot
Represents a snapshot of the current directory build from the latest Lucene commit.
|
static interface |
Store.OnClose
A listener that is executed once the store is closed and all references to it are released
|
static class |
Store.RecoveryDiff
A class representing the diff between a recovery source and recovery target
|
class |
Store.StoreDirectory
This exists so
BloomFilterPostingsFormat can load its boolean setting; can we find a more straightforward way? |
Modifier and Type | Field and Description |
---|---|
static String |
CHECKSUMS_PREFIX |
static String |
INDEX_STORE_STATS_REFRESH_INTERVAL |
componentSettings, indexSettings, logger, shardId
Constructor and Description |
---|
Store(ShardId shardId,
Settings indexSettings,
DirectoryService directoryService,
Distributor distributor,
ShardLock shardLock) |
Store(ShardId shardId,
Settings indexSettings,
DirectoryService directoryService,
Distributor distributor,
ShardLock shardLock,
Store.OnClose onClose) |
Modifier and Type | Method and Description |
---|---|
boolean |
checkIntegrity(StoreFileMetaData md) |
static boolean |
checkIntegrity(StoreFileMetaData md,
org.apache.lucene.store.Directory directory) |
void |
cleanup(String reason,
Set<String> filesToClean)
This method deletes every file in this store that is not contained in the given source meta data or is a
legacy checksum file.
|
void |
cleanupAndVerify(String reason,
Store.MetadataSnapshot sourceMetaData)
This method deletes every file in this store that is not contained in the given source meta data or is a
legacy checksum file.
|
void |
close()
Closes the index component.
|
org.apache.lucene.store.IndexOutput |
createVerifyingOutput(String fileName,
StoreFileMetaData metadata,
org.apache.lucene.store.IOContext context)
The returned IndexOutput might validate the files checksum if the file has been written with a newer lucene version
and the metadata holds the necessary information to detect that it was been written by Lucene 4.8 or newer.
|
void |
decRef()
Decreases the refCount of this Store instance.If the refCount drops to 0, then this
store is closed.
|
void |
deleteQuiet(String... files) |
static String |
digestToString(long digest)
Produces a string representation of the given digest value.
|
org.apache.lucene.store.Directory |
directory() |
void |
failIfCorrupted() |
Store.MetadataSnapshot |
getMetadata()
Returns a new MetadataSnapshot for the latest commit in this store.
|
Store.MetadataSnapshot |
getMetadata(org.apache.lucene.index.IndexCommit commit)
Returns a new MetadataSnapshot for the given commit.
|
Store.MetadataSnapshot |
getMetadataOrEmpty()
Returns a new MetadataSnapshot for the latest commit in this store or
an empty snapshot if no index exists or can not be opened.
|
void |
incRef()
Increments the refCount of this Store instance.
|
static boolean |
isChecksum(String name) |
boolean |
isMarkedCorrupted() |
static void |
logDeleteFile(org.apache.lucene.store.Directory dir,
String message,
String fileName)
Log that we are about to delete this file, to the index.store.deletes component.
|
void |
logDeleteFile(String message,
String fileName)
Log that we are about to delete this file, to the index.store.deletes component.
|
void |
markStoreCorrupted(org.apache.lucene.index.CorruptIndexException exception)
Marks this store as corrupted.
|
org.apache.lucene.store.IndexInput |
openVerifyingInput(String filename,
org.apache.lucene.store.IOContext context,
StoreFileMetaData metadata) |
org.apache.lucene.index.SegmentInfos |
readLastCommittedSegmentsInfo()
Returns the last committed segments info for this store
|
static Store.MetadataSnapshot |
readMetadataSnapshot(File[] indexLocations,
ESLogger logger)
Reads a MetadataSnapshot from the given index locations or returns an empty snapshot if it can't be read.
|
int |
refCount()
Returns the current reference count.
|
void |
renameFile(String from,
String to) |
void |
renameTempFilesSafe(Map<String,String> tempFileMap)
Renames all the given files form the key of the map to the
value of the map.
|
StoreStats |
stats() |
boolean |
tryIncRef()
Tries to increment the refCount of this Store instance.
|
static void |
verify(org.apache.lucene.store.IndexInput input) |
static void |
verify(org.apache.lucene.store.IndexOutput output) |
indexSettings, nodeName, shardId
public static final String INDEX_STORE_STATS_REFRESH_INTERVAL
public static final String CHECKSUMS_PREFIX
public Store(ShardId shardId, @IndexSettings Settings indexSettings, DirectoryService directoryService, Distributor distributor, ShardLock shardLock) throws IOException
IOException
@Inject public Store(ShardId shardId, @IndexSettings Settings indexSettings, DirectoryService directoryService, Distributor distributor, ShardLock shardLock, Store.OnClose onClose) throws IOException
IOException
public org.apache.lucene.store.Directory directory()
public org.apache.lucene.index.SegmentInfos readLastCommittedSegmentsInfo() throws IOException
IOException
- if the index is corrupted or the segments file is not presentpublic Store.MetadataSnapshot getMetadataOrEmpty() throws IOException
org.apache.lucene.index.CorruptIndexException
- if the lucene index is corrupted. This can be caused by a checksum mismatch or an
unexpected exception when opening the index reading the segments file.IOException
public Store.MetadataSnapshot getMetadata() throws IOException
org.apache.lucene.index.CorruptIndexException
- if the lucene index is corrupted. This can be caused by a checksum mismatch or an
unexpected exception when opening the index reading the segments file.FileNotFoundException
- if one or more files referenced by a commit are not present.NoSuchFileException
- if one or more files referenced by a commit are not present.org.apache.lucene.index.IndexNotFoundException
- if no index / valid commit-point can be found in this storeIOException
public Store.MetadataSnapshot getMetadata(org.apache.lucene.index.IndexCommit commit) throws IOException
null
the latest commit point is used.org.apache.lucene.index.CorruptIndexException
- if the lucene index is corrupted. This can be caused by a checksum mismatch or an
unexpected exception when opening the index reading the segments file.FileNotFoundException
- if one or more files referenced by a commit are not present.NoSuchFileException
- if one or more files referenced by a commit are not present.org.apache.lucene.index.IndexNotFoundException
- if the commit point can't be found in this storeIOException
public void renameTempFilesSafe(Map<String,String> tempFileMap) throws IOException
IOException
public StoreStats stats() throws IOException
IOException
public void renameFile(String from, String to) throws IOException
IOException
public final void incRef()
decRef()
, in a finally clause; otherwise the store may never be closed. Note that
close()
simply calls decRef(), which means that the Store will not really be closed until decRef()
has been called for all outstanding references.
Note: Close can safely be called multiple times.incRef
in interface RefCounted
org.apache.lucene.store.AlreadyClosedException
- iff the reference counter can not be incremented.decRef()
,
tryIncRef()
public final boolean tryIncRef()
decRef()
, in a finally clause; otherwise the store may never be closed. Note that
close()
simply calls decRef(), which means that the Store will not really be closed until decRef()
has been called for all outstanding references.
Note: Close can safely be called multiple times.tryIncRef
in interface RefCounted
decRef()
,
incRef()
public final void decRef()
decRef
in interface RefCounted
incRef()
public void close()
CloseableIndexComponent
close
in interface Closeable
close
in interface AutoCloseable
close
in interface CloseableIndexComponent
public static Store.MetadataSnapshot readMetadataSnapshot(File[] indexLocations, ESLogger logger) throws IOException
IOException
- if the index we try to read is corruptedpublic org.apache.lucene.store.IndexOutput createVerifyingOutput(String fileName, StoreFileMetaData metadata, org.apache.lucene.store.IOContext context) throws IOException
IOException
public static void verify(org.apache.lucene.store.IndexOutput output) throws IOException
IOException
public org.apache.lucene.store.IndexInput openVerifyingInput(String filename, org.apache.lucene.store.IOContext context, StoreFileMetaData metadata) throws IOException
IOException
public static void verify(org.apache.lucene.store.IndexInput input) throws IOException
IOException
public boolean checkIntegrity(StoreFileMetaData md)
public static boolean checkIntegrity(StoreFileMetaData md, org.apache.lucene.store.Directory directory)
public boolean isMarkedCorrupted() throws IOException
IOException
public void failIfCorrupted() throws IOException
IOException
public void cleanup(String reason, Set<String> filesToClean) throws IOException
reason
- the reason for this cleanup operation logged for each deleted filefilesToClean
- the file names used for cleanup. all files names in this metadata should be kept around.IOException
- if an IOException occurspublic void cleanupAndVerify(String reason, Store.MetadataSnapshot sourceMetaData) throws IOException
reason
- the reason for this cleanup operation logged for each deleted filesourceMetaData
- the metadata used for cleanup. all files in this metadata should be kept around.IOException
- if an IOException occursElasticsearchIllegalStateException
- if the latest snapshot in this store differs from the given one after the cleanup.public int refCount()
public void logDeleteFile(String message, String fileName)
public static void logDeleteFile(org.apache.lucene.store.Directory dir, String message, String fileName)
public static final boolean isChecksum(String name)
public static String digestToString(long digest)
public void deleteQuiet(String... files)
public void markStoreCorrupted(org.apache.lucene.index.CorruptIndexException exception) throws IOException
isMarkedCorrupted()
will return true
.IOException
Copyright © 2009–2015. All rights reserved.