public class EtcdAccessor extends Object
Modifier and Type | Field and Description |
---|---|
static String |
JOHNZON_SUPPORTS_COMMENTS_PROP
Property that make Johnzon accept commentc.
|
Constructor and Description |
---|
EtcdAccessor(String server)
Creates a new instance with the basic access url.
|
EtcdAccessor(String server,
int timeout) |
Modifier and Type | Method and Description |
---|---|
Map<String,String> |
delete(String key)
Deletes a given key.
|
Map<String,String> |
get(String key)
Ask etcd for a single key, value pair.
|
Map<String,String> |
getProperties(String directory)
Get all properties for the given directory key recursively.
|
Map<String,String> |
getProperties(String directory,
boolean recursive)
Access all properties.
|
String |
getUrl()
Access the server root URL used by this accessor.
|
String |
getVersion()
Get the etcd server version.
|
Map<String,String> |
set(String key,
String value)
Creates/updates an entry in etcd without any ttl set.
|
Map<String,String> |
set(String key,
String value,
Integer ttlSeconds)
Creates/updates an entry in etcd.
|
public static final String JOHNZON_SUPPORTS_COMMENTS_PROP
public EtcdAccessor(String server)
server
- server url, e.g. http://127.0.0.1:4001
, not null.public EtcdAccessor(String server, int timeout)
public String getVersion()
public Map<String,String> get(String key)
{ "action": "get", "node": { "createdIndex": 2, "key": "/message", "modifiedIndex": 2, "value": "Hello world" } }is mapped to:
key=value _key.source=[etcd]http://127.0.0.1:4001 _key.createdIndex=12 _key.modifiedIndex=34 _key.ttl=300 _key.expiration=...
key
- the requested keypublic Map<String,String> set(String key, String value)
key
- the property key, not nullvalue
- the value to be setset(String, String, Integer)
public Map<String,String> set(String key, String value, Integer ttlSeconds)
{ "action": "set", "node": { "createdIndex": 3, "key": "/message", "modifiedIndex": 3, "value": "Hello etcd" }, "prevNode": { "createdIndex": 2, "key": "/message", "value": "Hello world", "modifiedIndex": 2 } }is mapped to:
key=value _key.source=[etcd]http://127.0.0.1:4001 _key.createdIndex=12 _key.modifiedIndex=34 _key.ttl=300 _key.expiry=... // optional _key.prevNode.createdIndex=12 _key.prevNode.modifiedIndex=34 _key.prevNode.ttl=300 _key.prevNode.expiration=...
key
- the property key, not nullvalue
- the value to be setttlSeconds
- the ttl in seconds (optional)public Map<String,String> delete(String key)
_key.source=[etcd]http://127.0.0.1:4001 _key.createdIndex=12 _key.modifiedIndex=34 _key.ttl=300 _key.expiry=... // optional _key.prevNode.createdIndex=12 _key.prevNode.modifiedIndex=34 _key.prevNode.ttl=300 _key.prevNode.expiration=... _key.prevNode.value=...
key
- the key to be deleted.public Map<String,String> getProperties(String directory)
directory
- the directory entrygetProperties(String, boolean)
public Map<String,String> getProperties(String directory, boolean recursive)
{ "action": "get", "node": { "key": "/", "dir": true, "nodes": [ { "key": "/foo_dir", "dir": true, "modifiedIndex": 2, "createdIndex": 2 }, { "key": "/foo", "value": "two", "modifiedIndex": 1, "createdIndex": 1 } ] } }is mapped to a regular Tamaya properties map as follows:
key1=myvalue _key1.source=[etcd]http://127.0.0.1:4001 _key1.createdIndex=12 _key1.modifiedIndex=34 _key1.ttl=300 _key1.expiration=... key2=myvaluexxx _key2.source=[etcd]http://127.0.0.1:4001 _key2.createdIndex=12 key3=val3 _key3.source=[etcd]http://127.0.0.1:4001 _key3.createdIndex=12 _key3.modifiedIndex=2
directory
- remote directory to query.recursive
- allows to set if querying is performed recursivelypublic String getUrl()
Copyright © 2014–2016 Apache Software Foundation. All rights reserved.