public class WaitNotifyProtocol extends Object
Modifier and Type | Class and Description |
---|---|
static class |
WaitNotifyProtocol.Signal |
Modifier and Type | Field and Description |
---|---|
private AtomicDistributedMapCacheClient |
cache |
static String |
CONSUMED_COUNT_NAME |
static String |
DEFAULT_COUNT_NAME |
private static org.slf4j.Logger |
logger |
private static int |
MAX_REPLACE_RETRY_COUNT |
private static com.fasterxml.jackson.databind.ObjectMapper |
objectMapper |
private static int |
REPLACE_RETRY_WAIT_MILLIS |
private Deserializer<String> |
stringDeserializer |
private static Serializer<String> |
stringSerializer |
Constructor and Description |
---|
WaitNotifyProtocol(AtomicDistributedMapCacheClient cache) |
Modifier and Type | Method and Description |
---|---|
void |
complete(String signalId)
Finish protocol and remove the cache entry.
|
WaitNotifyProtocol.Signal |
getSignal(String signalId)
Retrieve a stored Signal in the cache engine.
|
WaitNotifyProtocol.Signal |
notify(String signalId,
Map<String,Integer> deltas,
Map<String,String> attributes)
Notify a signal to increase a counter.
|
WaitNotifyProtocol.Signal |
notify(String signalId,
String counterName,
int delta,
Map<String,String> attributes)
Notify a signal to increase a counter.
|
boolean |
replace(WaitNotifyProtocol.Signal signal) |
private static final org.slf4j.Logger logger
public static final String DEFAULT_COUNT_NAME
public static final String CONSUMED_COUNT_NAME
private static final int MAX_REPLACE_RETRY_COUNT
private static final int REPLACE_RETRY_WAIT_MILLIS
private static final com.fasterxml.jackson.databind.ObjectMapper objectMapper
private static final Serializer<String> stringSerializer
private final Deserializer<String> stringDeserializer
private final AtomicDistributedMapCacheClient cache
public WaitNotifyProtocol(AtomicDistributedMapCacheClient cache)
public WaitNotifyProtocol.Signal notify(String signalId, Map<String,Integer> deltas, Map<String,String> attributes) throws IOException, ConcurrentModificationException
signalId
- a key in the underlying cache enginedeltas
- a map containing counterName and delta entries, 0 has special meaning, clears the counter back to 0attributes
- attributes to save in the cache entryIOException
- thrown when it failed interacting with the cache engineConcurrentModificationException
- thrown if other process is also updating the same signal and failed to update after few retry attemptspublic WaitNotifyProtocol.Signal notify(String signalId, String counterName, int delta, Map<String,String> attributes) throws IOException, ConcurrentModificationException
signalId
- a key in the underlying cache enginecounterName
- specify count to updatedelta
- delta to update a counter, 0 has special meaning, clears the counter back to 0attributes
- attributes to save in the cache entryIOException
- thrown when it failed interacting with the cache engineConcurrentModificationException
- thrown if other process is also updating the same signal and failed to update after few retry attemptspublic WaitNotifyProtocol.Signal getSignal(String signalId) throws IOException, DeserializationException
complete(String)
to complete the Wait Notify protocol.signalId
- a key in the underlying cache engineIOException
- thrown when it failed interacting with the cache engineDeserializationException
- thrown if the cache found is not in expected serialized formatpublic void complete(String signalId) throws IOException
signalId
- a key in the underlying cache engineIOException
- thrown when it failed interacting with the cache enginepublic boolean replace(WaitNotifyProtocol.Signal signal) throws IOException
IOException
Copyright © 2018 Apache NiFi Project. All rights reserved.