public class HollowProducer
extends java.lang.Object
To obtain a HollowProducer, you should use a builder pattern, for example:
HollowProducer producer = HollowProducer.withPublisher(publisher)
.withAnnouncer(announcer)
.build();
The following components are injectable, but only an implementation of the HollowProducer.Publisher is required to be injected, all other components are optional. :
HollowProducer.Publisher
HollowProducer.Announcer
ValidatorListener
that allow for semantic validation of the data contained in
a state prior to announcement. If a RuntimeException
is thrown during validation, the state will not be
announced, and the producer will be automatically rolled back to the prior state.
HollowProducer.BlobCompressor
HollowProducer.BlobStager
HollowProducer.BlobStager
is provided, then neither a blob staging directory or HollowProducer.BlobCompressor
should be provided.HollowProducer.VersionMinter
Modifier and Type | Class and Description |
---|---|
static interface |
HollowProducer.Announcer |
static class |
HollowProducer.Blob |
static interface |
HollowProducer.BlobCompressor |
static interface |
HollowProducer.BlobStager |
static class |
HollowProducer.BlobStorageCleaner
Provides the opportunity to clean the blob storage.
|
static class |
HollowProducer.Builder<B extends HollowProducer.Builder<B>> |
static class |
HollowProducer.ChecksumValidationException |
static class |
HollowProducer.Incremental
A producer of Hollow data that populates with given data changes (addition, modification or removal), termed
incremental production.
|
static interface |
HollowProducer.Populator
Represents a task that populates a new data state within a
HollowProducer cycle. |
static interface |
HollowProducer.Publisher |
static interface |
HollowProducer.ReadState
Representation of read state computed from the population of new write state.
|
static interface |
HollowProducer.VersionMinter |
static interface |
HollowProducer.WriteState
Representation of new write state.
|
Modifier | Constructor and Description |
---|---|
protected |
HollowProducer(HollowProducer.Builder<?> b) |
|
HollowProducer(HollowProducer.Publisher publisher,
HollowProducer.Announcer announcer)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(HollowProducerEventListener listener)
Adds a listener to this producer.
|
void |
addListener(HollowProducerListener listener)
Adds a listener to this producer.
|
boolean |
enablePrimaryProducer(boolean doEnable)
Invoke this method to alter runCycle behavior.
|
HollowProducerMetrics |
getMetrics() |
HollowObjectMapper |
getObjectMapper() |
HollowWriteStateEngine |
getWriteEngine() |
void |
initializeDataModel(java.lang.Class<?>... classes)
Initializes the data model for the given classes.
|
void |
initializeDataModel(HollowSchema... schemas)
Initializes the producer data model for the given schemas.
|
void |
removeListener(HollowProducerEventListener listener)
Removes a listener to this producer.
|
void |
removeListener(HollowProducerListener listener)
Removes a listener to this producer.
|
HollowProducer.ReadState |
restore(long versionDesired,
HollowConsumer.BlobRetriever blobRetriever)
Restores the data state to a desired version.
|
long |
runCompactionCycle(HollowCompactor.CompactionConfig config)
Run a compaction cycle, will produce a data state with exactly the same data as currently, but
reorganized so that ordinal holes are filled.
|
long |
runCycle(HollowProducer.Populator task)
Runs a cycle to populate, publish, and announce a new single data state.
|
static HollowProducer.Builder<?> |
withPublisher(HollowProducer.Publisher publisher) |
@Deprecated public HollowProducer(HollowProducer.Publisher publisher, HollowProducer.Announcer announcer)
protected HollowProducer(HollowProducer.Builder<?> b)
public HollowProducerMetrics getMetrics()
public void initializeDataModel(java.lang.Class<?>... classes)
Data model initialization is required prior to restoring
the producer.
This ensures that restoration can correctly compare the producer's current data model
with the data model of the restored data state and manage any differences in those models
(such as not restoring state for any types in the restoring data model not present in the
producer's current data model).
After initialization a data model initialization event will be emitted
to all registered data model initialization listeners
listeners
.
classes
- the data model classesjava.lang.IllegalArgumentException
- if classes
is emptyrestore(long, HollowConsumer.BlobRetriever)
public void initializeDataModel(HollowSchema... schemas)
Data model initialization is required prior to restoring
the producer.
This ensures that restoration can correctly compare the producer's current data model
with the data model of the restored data state and manage any differences in those models
(such as not restoring state for any types in the restoring data model not present in the
producer's current data model).
After initialization a data model initialization event will be emitted
to all registered data model initialization listeners
listeners
.
schemas
- the data model classesjava.lang.IllegalArgumentException
- if schemas
is emptyrestore(long, HollowConsumer.BlobRetriever)
public HollowProducer.ReadState restore(long versionDesired, HollowConsumer.BlobRetriever blobRetriever)
Data model initialization
is required prior to
restoring the producer. This ensures that restoration can correctly compare the producer's
current data model with the data model of the restored data state and manage any differences
in those models (such as not restoring state for any types in the restoring data model not
present in the producer's current data model)
versionDesired
- the desired versionblobRetriever
- the blob retrieverjava.lang.IllegalStateException
- if the producer's data model has not been initializedinitializeDataModel(Class[])
public HollowWriteStateEngine getWriteEngine()
public HollowObjectMapper getObjectMapper()
public boolean enablePrimaryProducer(boolean doEnable)
doEnable
- true if enable primary producer, if falsepublic long runCycle(HollowProducer.Populator task)
task
- the populating task to add complete statejava.lang.RuntimeException
- if the cycle failedpublic long runCompactionCycle(HollowCompactor.CompactionConfig config)
config
- specifies what criteria to use to determine whether a compaction is necessarypublic void addListener(HollowProducerListener listener)
If the listener was previously added to this consumer, as determined by reference equality or Object
equality, then this method does nothing.
If a listener is added, concurrently, during the occurrence of a cycle or restore then the listener will not receive events until the next cycle or restore. The listener may also be removed concurrently.
listener
- the listener to addpublic void addListener(HollowProducerEventListener listener)
If the listener was previously added to this consumer, as determined by reference equality or Object
equality, then this method does nothing.
If a listener is added, concurrently, during the occurrence of a cycle or restore then the listener will not receive events until the next cycle or restore. The listener may also be removed concurrently.
listener
- the listener to addpublic void removeListener(HollowProducerListener listener)
If the listener was not previously added to this producer, as determined by reference equality or Object
equality, then this method does nothing.
If a listener is removed, concurrently, during the occurrence of a cycle or restore then the listener will receive all events for that cycle or restore but not receive events for a subsequent cycle or restore.
listener
- the listener to removepublic void removeListener(HollowProducerEventListener listener)
If the listener was not previously added to this producer, as determined by reference equality or Object
equality, then this method does nothing.
If a listener is removed, concurrently, during the occurrence of a cycle or restore then the listener will receive all events for that cycle or restore but not receive events for a subsequent cycle or restore.
listener
- the listener to removepublic static HollowProducer.Builder<?> withPublisher(HollowProducer.Publisher publisher)