Interface NodeValueCodec


public interface NodeValueCodec
Decode and encode between list of zNode value strings and list of Endpoints.
  • Method Details

    • ofDefault

      static NodeValueCodec ofDefault()
      Returns the default NodeValueCodec 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
      the segment and field delimiter can be specified, default will be "," and ":" Note that the port number must be specified when you want to specify the weight.
    • decodeAll

      default Set<Endpoint> decodeAll​(byte[] zNodeValue)
      Decodes a zNode value into a set of Endpoints.
      Parameters:
      zNodeValue - zNode value
      Returns:
      the list of Endpoints
    • decodeAll

      Set<Endpoint> decodeAll​(String zNodeValue)
      Decodes a zNode value into a set of Endpoints.
      Parameters:
      zNodeValue - zNode value
      Returns:
      the list of Endpoints
    • decode

      @Nullable default Endpoint decode​(byte[] zNodeValue)
      Decodes a zNode value to a Endpoint.
      Parameters:
      zNodeValue - ZooKeeper node value
      Returns:
      an Endpoint or null if value needs to be skipped
    • decode

      @Nullable Endpoint decode​(String zNodeValue)
      Decodes a zNode value to a Endpoint.
      Parameters:
      zNodeValue - ZooKeeper node value
      Returns:
      an Endpoint or null if value needs to be skipped
    • encodeAll

      byte[] encodeAll​(Iterable<Endpoint> endpoints)
      Encodes a set of Endpoints into a byte array representation.
      Parameters:
      endpoints - set of Endpoints
      Returns:
      a byte array
    • encode

      byte[] encode​(Endpoint endpoint)
      Encodes a single Endpoint into a byte array representation.
      Parameters:
      endpoint - an Endpoint
      Returns:
      a byte array