Class EtcdClient


  • public class EtcdClient
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      EtcdClient​(java.lang.String endpoints, java.lang.String namespace)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      long delete​(java.lang.String key)  
      long deleteAllKvsInNamespace()  
      long deleteWithPrefix​(java.lang.String prefix)  
      byte[] get​(java.lang.String key)
      Returns the value to which the specified key is mapped.
      byte[] get​(java.lang.String key, boolean throwException)
      Returns the value to which the specified key is mapped.
      byte[] get​(java.lang.String key, long timeout, long logInterval)
      Returns the value to which the specified key is mapped.
      protected io.etcd.jetcd.KV getKv()  
      java.util.List<byte[]> getWithPrefix​(java.lang.String prefix)
      Get the values of keys with the specified prefix.
      java.util.List<byte[]> getWithPrefix​(java.lang.String prefix, int count)
      Get the expected count of values of keys with the specified prefix.
      java.util.List<byte[]> getWithPrefix​(java.lang.String prefix, int count, long timeout, long logInterval)
      Get expected count of values with the key prefix with prefix.
      void put​(java.lang.String key, byte[] value)
      Put the key value mapping to the map, if the map previously contained a mapping for the key, the old value is replaced by the specified value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EtcdClient

        public EtcdClient​(java.lang.String endpoints,
                          java.lang.String namespace)
    • Method Detail

      • put

        public void put​(java.lang.String key,
                        byte[] value)
        Put the key value mapping to the map, if the map previously contained a mapping for the key, the old value is replaced by the specified value.
        Parameters:
        key - key with which the specified value is to be associated
        value - value to be associated with the specified key
      • get

        public byte[] get​(java.lang.String key)
        Returns the value to which the specified key is mapped.
        Parameters:
        key - The key to be found
        Returns:
        the value of specified key, null if not found
      • get

        public byte[] get​(java.lang.String key,
                          boolean throwException)
        Returns the value to which the specified key is mapped.
        Parameters:
        key - The key to be found
        throwException - whether to throw ComputerException if not found.
        Returns:
        the value of specified key, null if not found and throwException is set false
        Throws:
        org.apache.hugegraph.computer.core.common.exception.ComputerException - if not found and throwException is set true
      • get

        public byte[] get​(java.lang.String key,
                          long timeout,
                          long logInterval)
        Returns the value to which the specified key is mapped. If no key exists, wait at most timeout milliseconds. Or throw ComputerException if timeout
        Parameters:
        key - the key whose associated value is to be returned.
        timeout - the max time in milliseconds to wait.
        Returns:
        the specified value in byte array to which the specified key is mapped.
      • getWithPrefix

        public java.util.List<byte[]> getWithPrefix​(java.lang.String prefix)
        Get the values of keys with the specified prefix. If no key found, return empty list.
      • getWithPrefix

        public java.util.List<byte[]> getWithPrefix​(java.lang.String prefix,
                                                    int count)
        Get the expected count of values of keys with the specified prefix. Throws ComputerException if there are no enough object.
      • getWithPrefix

        public java.util.List<byte[]> getWithPrefix​(java.lang.String prefix,
                                                    int count,
                                                    long timeout,
                                                    long logInterval)
        Get expected count of values with the key prefix with prefix. If there is no count of keys, wait at most timeout milliseconds.
        Parameters:
        prefix - the key prefix
        count - the expected count of values to be get
        timeout - the max wait time
        logInterval - the interval in ms to log message
        Returns:
        the list of values which key with specified prefix
      • delete

        public long delete​(java.lang.String key)
        Returns:
        1 if deleted specified key, 0 if not found specified key The deleted data can be get through revision, if revision is compacted, throw exception "etcdserver: mvcc: required revision has been compacted".
        See Also:
        Maintenance
      • deleteWithPrefix

        public long deleteWithPrefix​(java.lang.String prefix)
        Returns:
        the number of keys deleted
      • deleteAllKvsInNamespace

        public long deleteAllKvsInNamespace()
      • close

        public void close()
      • getKv

        protected io.etcd.jetcd.KV getKv()