T - the type of the XContent base data-structurepublic abstract class MetaDataStateFormat<T> extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
STATE_DIR_NAME |
static String |
STATE_FILE_EXTENSION |
| Modifier | Constructor and Description |
|---|---|
protected |
MetaDataStateFormat(XContentType format,
String prefix)
Creates a new
MetaDataStateFormat instance |
| Modifier and Type | Method and Description |
|---|---|
static void |
deleteMetaState(Path... dataLocations)
Deletes all meta state directories recursively for the given data locations
|
XContentType |
format()
Returns the
XContentType used to serialize xcontent on write. |
abstract T |
fromXContent(XContentParser parser)
Reads a new instance of the state from the given XContentParser
Subclasses need to implement this class for theirs specific state.
|
T |
loadLatestState(ESLogger logger,
Path... dataLocations)
Tries to load the latest state from the given data-locations.
|
protected org.apache.lucene.store.Directory |
newDirectory(Path dir) |
protected XContentBuilder |
newXContentBuilder(XContentType type,
OutputStream stream) |
T |
read(Path file)
Reads the state from a given file and compares the expected version against the actual version of
the state.
|
abstract void |
toXContent(XContentBuilder builder,
T state)
Writes the given state to the given XContentBuilder
Subclasses need to implement this class for theirs specific state.
|
void |
write(T state,
long version,
Path... locations)
Writes the given state to the given directories.
|
public static final String STATE_DIR_NAME
public static final String STATE_FILE_EXTENSION
protected MetaDataStateFormat(XContentType format, String prefix)
MetaDataStateFormat instanceformat - the format of the x-contentpublic XContentType format()
XContentType used to serialize xcontent on write.public final void write(T state, long version, Path... locations) throws IOException
state - the state object to writeversion - the version of the statelocations - the locations where the state should be written to.IOException - if an IOException occursprotected XContentBuilder newXContentBuilder(XContentType type, OutputStream stream) throws IOException
IOExceptionpublic abstract void toXContent(XContentBuilder builder, T state) throws IOException
IOExceptionpublic abstract T fromXContent(XContentParser parser) throws IOException
IOExceptionpublic final T read(Path file) throws IOException
IOExceptionprotected org.apache.lucene.store.Directory newDirectory(Path dir) throws IOException
IOExceptionpublic T loadLatestState(ESLogger logger, Path... dataLocations) throws IOException
logger - an elasticsearch logger instancedataLocations - the data-locations to try.null if no state was found.IOExceptionpublic static void deleteMetaState(Path... dataLocations) throws IOException
dataLocations - the data location to deleteIOExceptionCopyright © 2009–2016. All rights reserved.