T - the type of the XContent base data-structurepublic abstract class MetaDataStateFormat<T>
extends java.lang.Object
| Modifier and Type | Field | Description |
|---|---|---|
static XContentType |
FORMAT |
|
static java.lang.String |
STATE_DIR_NAME |
|
static java.lang.String |
STATE_FILE_EXTENSION |
| Modifier | Constructor | Description |
|---|---|---|
protected |
MetaDataStateFormat(java.lang.String prefix) |
Creates a new
MetaDataStateFormat instance |
| Modifier and Type | Method | Description |
|---|---|---|
static void |
deleteMetaState(java.nio.file.Path... dataLocations) |
Deletes all meta state directories recursively for the given data locations
|
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(org.apache.logging.log4j.Logger logger,
NamedXContentRegistry namedXContentRegistry,
java.nio.file.Path... dataLocations) |
Tries to load the latest state from the given data-locations.
|
protected org.apache.lucene.store.Directory |
newDirectory(java.nio.file.Path dir) |
|
protected XContentBuilder |
newXContentBuilder(XContentType type,
java.io.OutputStream stream) |
|
T |
read(NamedXContentRegistry namedXContentRegistry,
java.nio.file.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,
java.nio.file.Path... locations) |
Writes the given state to the given directories.
|
public static final XContentType FORMAT
public static final java.lang.String STATE_DIR_NAME
public static final java.lang.String STATE_FILE_EXTENSION
protected MetaDataStateFormat(java.lang.String prefix)
MetaDataStateFormat instancepublic final void write(T state, java.nio.file.Path... locations) throws java.io.IOException
state - the state object to writelocations - the locations where the state should be written to.java.io.IOException - if an IOException occursprotected XContentBuilder newXContentBuilder(XContentType type, java.io.OutputStream stream) throws java.io.IOException
java.io.IOExceptionpublic abstract void toXContent(XContentBuilder builder, T state) throws java.io.IOException
java.io.IOExceptionpublic abstract T fromXContent(XContentParser parser) throws java.io.IOException
java.io.IOExceptionpublic final T read(NamedXContentRegistry namedXContentRegistry, java.nio.file.Path file) throws java.io.IOException
java.io.IOExceptionprotected org.apache.lucene.store.Directory newDirectory(java.nio.file.Path dir)
throws java.io.IOException
java.io.IOExceptionpublic T loadLatestState(org.apache.logging.log4j.Logger logger, NamedXContentRegistry namedXContentRegistry, java.nio.file.Path... dataLocations) throws java.io.IOException
logger - a logger instancedataLocations - the data-locations to try.null if no state was found.java.io.IOExceptionpublic static void deleteMetaState(java.nio.file.Path... dataLocations)
throws java.io.IOException
dataLocations - the data location to deletejava.io.IOException