T
- the type of the XContent base data-structurepublic abstract class MetaDataStateFormat<T>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
STATE_DIR_NAME |
static java.lang.String |
STATE_FILE_EXTENSION |
Modifier | Constructor and Description |
---|---|
protected |
MetaDataStateFormat(XContentType format,
java.lang.String prefix)
Creates a new
MetaDataStateFormat instance |
Modifier and Type | Method and Description |
---|---|
static void |
deleteMetaState(java.nio.file.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(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 java.lang.String STATE_DIR_NAME
public static final java.lang.String STATE_FILE_EXTENSION
protected MetaDataStateFormat(XContentType format, java.lang.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, 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.IOException
public abstract void toXContent(XContentBuilder builder, T state) throws java.io.IOException
java.io.IOException
public abstract T fromXContent(XContentParser parser) throws java.io.IOException
java.io.IOException
public final T read(NamedXContentRegistry namedXContentRegistry, java.nio.file.Path file) throws java.io.IOException
java.io.IOException
protected org.apache.lucene.store.Directory newDirectory(java.nio.file.Path dir) throws java.io.IOException
java.io.IOException
public 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.IOException
public static void deleteMetaState(java.nio.file.Path... dataLocations) throws java.io.IOException
dataLocations
- the data location to deletejava.io.IOException