public abstract class AbstractPubSubInvalidator<T extends SerializableInvalidations> extends Object
PubSubService
.
All nodes that use the same topic will share the same invalidations.
The discriminator is used to distinguish nodes between one another, and to avoid that a node receives the invalidations it send itself.
Modifier and Type | Field and Description |
---|---|
protected T |
bufferedInvalidations |
protected static byte |
DISCRIMINATOR_SEP |
protected byte[] |
discriminatorBytes |
protected String |
topic |
Constructor and Description |
---|
AbstractPubSubInvalidator() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this invalidator and releases resources.
|
abstract T |
deserialize(InputStream in)
Deserializes an
InputStream into invalidations, or null . |
void |
initialize(String topic,
String discriminator)
Initializes the invalidator.
|
abstract T |
newInvalidations()
Constructs new empty invalidations, of type
T . |
T |
receiveInvalidations()
Receives invalidations from other nodes.
|
protected int |
scanDiscriminator(byte[] message)
Scans for the discriminator and returns the payload start offset.
|
void |
sendInvalidations(T invalidations)
Sends invalidations to other nodes.
|
protected void |
subscriber(String topic,
byte[] message)
PubSubService subscriber, called from a separate thread.
|
protected byte[] discriminatorBytes
protected volatile T extends SerializableInvalidations bufferedInvalidations
protected static final byte DISCRIMINATOR_SEP
public AbstractPubSubInvalidator()
public abstract T newInvalidations()
T
.public abstract T deserialize(InputStream in) throws IOException
InputStream
into invalidations, or null
.IOException
public void initialize(String topic, String discriminator)
topic
- the topicdiscriminator
- the discriminatorpublic void close()
public void sendInvalidations(T invalidations)
protected void subscriber(String topic, byte[] message)
protected int scanDiscriminator(byte[] message)
public T receiveInvalidations()
Copyright © 2017 Nuxeo. All rights reserved.