asyncMultiSet

异步写同一HashKey下的多行数据。

  1. public static interface MultiSetListener extends GenericFutureListener<Future<Void>> {
  2. /**
  3. * This function will be called when listened asyncMultiSet future is done.
  4. * @param future the listened future
  5. * @throws Exception
  6. *
  7. * Notice: User shouldn't do any operations that may block or time-consuming
  8. */
  9. @Override
  10. public void operationComplete(Future<Void> future) throws Exception;
  11. }
  12.  
  13. /**
  14. * Set key-values for a specific hashKey, async version
  15. * @param hashKey used to decide which partition the key may exist
  16. * if null or empty, means hash key is "".
  17. * @param values all (sortKey, value) pairs
  18. * should not be null or empty
  19. * @param ttlSeconds time to live in seconds
  20. * 0 means no ttl, default value is 0
  21. * @param timeout how long will the operation timeout in milliseconds.
  22. * if timeout > 0, it is a timeout value for current op,
  23. * else the timeout value in the configuration file will be used.
  24. *
  25. * @return the future for current op
  26. *
  27. * Future return:
  28. * On success: no return
  29. * On failure: a throwable, which is an instance of PException
  30. *
  31. * Thread safety:
  32. * All the listeners for the same table are guaranteed to be dispatched in the same thread, so all the
  33. * listeners for the same future are guaranteed to be executed as the same order as the listeners added.
  34. * But listeners for different tables are not guaranteed to be dispatched in the same thread.
  35. */
  36. public Future<Void> asyncMultiSet(byte[] hashKey, List<Pair<byte[], byte[]>> values, int ttlSeconds, int timeout/*ms*/);
  37. public Future<Void> asyncMultiSet(byte[] hashKey, List<Pair<byte[], byte[]>> values, int timeout/*ms*/);

注:

  • 提供了两个版本的接口,其中第一个接口可以指定TTL时间。
  • 参数:需传入HashKey、Values、timeout;选择性传入ttlSeconds。
    • Values是Pair列表,Pair的第一个元素是SortKey,第二个元素为value。
    • timeout单位为毫秒,如果<=0,表示使用配置文件中的默认超时。
    • ttlSeconds是数据的TTL时间,单位为秒。0表示不设置TTL时间。
  • 返回值:Future