public class NettyDistributedMapCacheClient extends DistributedCacheClient
DistributedMapCacheClient using the netty library to provide the remote
communication services.| Constructor and Description |
|---|
NettyDistributedMapCacheClient(String hostname,
int port,
int timeoutMillis,
SSLContextService sslContextService,
VersionNegotiatorFactory factory)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Perform a clean shutdown of the cache client.
|
boolean |
containsKey(byte[] key)
Determines if the given value is present in the cache and if so returns
true, else returns false |
<K,V> AtomicCacheEntry<K,V,Long> |
fetch(byte[] key,
AtomicCacheEntryInboundAdapter<K,V> inboundAdapter)
Fetch a CacheEntry with a key.
|
<V> V |
get(byte[] key,
ValueInboundAdapter<V> valueAdapter)
Returns the value in the cache for the given key, if one exists;
otherwise returns
null |
<V> V |
getAndPutIfAbsent(byte[] key,
byte[] value,
ValueInboundAdapter<V> valueAdapter)
Adds the specified key and value to the cache, if they are not already
present.
|
<K> Set<K> |
keySet(SetInboundAdapter<K> setAdapter)
Returns a set of all keys currently in the cache.
|
void |
put(byte[] key,
byte[] value)
Adds the specified key and value to the cache, overwriting any value that is
currently set.
|
boolean |
putIfAbsent(byte[] key,
byte[] value)
Adds the specified key and value to the cache, if they are not already
present.
|
boolean |
remove(byte[] key)
Removes the entry with the given key from the cache, if it is present.
|
<V> V |
removeAndGet(byte[] key,
ValueInboundAdapter<V> valueAdapter)
Removes the entry with the given key from the cache, if it is present,
and returns the value that was removed from the map.
|
long |
removeByPattern(String regex)
Removes entries whose keys match the specified pattern.
|
<K,V> Map<K,V> |
removeByPatternAndGet(String regex,
MapInboundAdapter<K,V> mapAdapter)
Removes entries whose keys match the specified pattern, and returns a map of entries that
were removed.
|
boolean |
replace(byte[] key,
byte[] value,
long revision)
Replace an existing key with new value.
|
<K,V> Map<K,V> |
subMap(Collection<byte[]> keys,
MapValuesInboundAdapter<K,V> mapAdapter)
Returns the values in the cache for the given keys, if they exist.
|
closeChannelPool, invokepublic NettyDistributedMapCacheClient(String hostname, int port, int timeoutMillis, SSLContextService sslContextService, VersionNegotiatorFactory factory)
hostname - the network name / IP address of the server running the distributed cache serviceport - the port on which the distributed cache service is runningtimeoutMillis - the network timeout associated with requests to the servicesslContextService - the SSL context (if any) associated with requests to the service; if not specified,
communications will not be encryptedfactory - creator of object used to broker the version of the distributed cache protocol with the servicepublic boolean putIfAbsent(byte[] key,
byte[] value)
throws IOException
key - the key to add to the mapvalue - the value to add to the map if and only if the key is absentIOException - if unable to communicate with the remote instancepublic void put(byte[] key,
byte[] value)
throws IOException
key - The key to setvalue - The value to associate with the given KeyIOException - if unable to communicate with the remote instancepublic boolean containsKey(byte[] key)
throws IOException
true, else returns falsekey - keytrue, else returns falseIOException - if unable to communicate with the remote instancepublic <V> V getAndPutIfAbsent(byte[] key,
byte[] value,
ValueInboundAdapter<V> valueAdapter)
throws IOException
key - the key to add to the mapvalue - the value to add to the map if and only if the key is absentvalueAdapter - the reader used to deserialize the service resultIOException - if unable to communicate with the remote instancepublic <V> V get(byte[] key,
ValueInboundAdapter<V> valueAdapter)
throws IOException
nullV - the value typekey - the key to lookup in the mapvalueAdapter - the reader used to deserialize the service resultIOException - if unable to communicate with the remote instancepublic <K,V> Map<K,V> subMap(Collection<byte[]> keys, MapValuesInboundAdapter<K,V> mapAdapter) throws IOException
K - the key typeV - the value typekeys - a set of keys whose values to lookup in the mapmapAdapter - the reader used to deserialize the service resultIOException - if unable to communicate with the remote instancepublic boolean remove(byte[] key)
throws IOException
key - the key to remove from the maptrue if the entry is removed, false if
the key did not exist in the cacheIOException - if unable to communicate with the remote instancepublic <V> V removeAndGet(byte[] key,
ValueInboundAdapter<V> valueAdapter)
throws IOException
V - type of valuekey - the key to remove from the mapvalueAdapter - the reader used to deserialize the service resultIOException - if unable to communicate with the remote instancepublic long removeByPattern(String regex) throws IOException
regex - The regular expression / pattern on which to match the keys to be removedIOException - if unable to communicate with the remote instancepublic <K,V> Map<K,V> removeByPatternAndGet(String regex, MapInboundAdapter<K,V> mapAdapter) throws IOException
K - type of keyV - type of valueregex - The regular expression / pattern on which to match the keys to be removedIOException - if unable to communicate with the remote instancepublic <K,V> AtomicCacheEntry<K,V,Long> fetch(byte[] key, AtomicCacheEntryInboundAdapter<K,V> inboundAdapter) throws IOException
K - the key typeV - the value typekey - the key to lookup in the mapinboundAdapter - the reader used to deserialize the service resultIOException - if unable to communicate with the remote instancepublic boolean replace(byte[] key,
byte[] value,
long revision)
throws IOException
key - the key of the map entry to be replacedvalue - the new valuerevision - the expected revision of the map entry; on no match, value will not be replacedIOException - if unable to communicate with the remote instancepublic <K> Set<K> keySet(SetInboundAdapter<K> setAdapter) throws IOException
K - type of keysetAdapter - the reader used to deserialize the service resultIOException - if unable to communicate with the remote instancepublic void close()
throws IOException
IOException - if unable to communicate with the remote instanceCopyright © 2022 Apache NiFi Project. All rights reserved.