Interface NodeValueCodec
public interface NodeValueCodec
Decode and encode between list of zNode value strings and list of
Endpoint
s.-
Method Summary
Modifier and Type Method Description default Endpoint
decode(byte[] zNodeValue)
Decodes a zNode value to aEndpoint
.Endpoint
decode(String zNodeValue)
Decodes a zNode value to aEndpoint
.default Set<Endpoint>
decodeAll(byte[] zNodeValue)
Decodes a zNode value into a set ofEndpoint
s.Set<Endpoint>
decodeAll(String zNodeValue)
Decodes a zNode value into a set ofEndpoint
s.byte[]
encode(Endpoint endpoint)
Encodes a singleEndpoint
into a byte array representation.byte[]
encodeAll(Iterable<Endpoint> endpoints)
Encodes a set ofEndpoint
s into a byte array representation.static NodeValueCodec
ofDefault()
Returns the defaultNodeValueCodec
implementation which assumes zNode value is a comma-separated string.
-
Method Details
-
ofDefault
Returns the defaultNodeValueCodec
implementation which assumes zNode value is a comma-separated string. Each element of the zNode value represents an endpoint whose format is<host>[:<port_number>[:weight]]
, such as:"foo.com"
- default port number, default weight (1000)"bar.com:8080
- port number 8080, default weight (1000)"10.0.2.15:0:500
- default port number, weight 500"192.168.1.2:8443:700
- port number 8443, weight 700
-
decodeAll
Decodes a zNode value into a set ofEndpoint
s.- Parameters:
zNodeValue
- zNode value- Returns:
- the list of
Endpoint
s
-
decodeAll
Decodes a zNode value into a set ofEndpoint
s.- Parameters:
zNodeValue
- zNode value- Returns:
- the list of
Endpoint
s
-
decode
Decodes a zNode value to aEndpoint
.- Parameters:
zNodeValue
- ZooKeeper node value- Returns:
- an
Endpoint
ornull
if value needs to be skipped
-
decode
Decodes a zNode value to aEndpoint
.- Parameters:
zNodeValue
- ZooKeeper node value- Returns:
- an
Endpoint
ornull
if value needs to be skipped
-
encodeAll
Encodes a set ofEndpoint
s into a byte array representation.- Parameters:
endpoints
- set ofEndpoint
s- Returns:
- a byte array
-
encode
Encodes a singleEndpoint
into a byte array representation.- Parameters:
endpoint
- anEndpoint
- Returns:
- a byte array
-