Ejemplo n.º 1
0
  /**
   * Description: <br>
   *
   * @author 王伟<br>
   * @taskId <br>
   * @param clazz
   * @param nodeName
   * @return
   * @throws CacheException <br>
   */
  @Override
  public <T> Map<String, T> getNode(Class<T> clazz, String nodeName) throws CacheException {
    Map<String, T> map = null;
    try {
      Map<byte[], byte[]> hmap = cluster.hgetAllBytes(nodeName);
      if (CommonUtil.isNotEmpty(hmap)) {
        map = new HashMap<String, T>();
        for (Entry<byte[], byte[]> entry : hmap.entrySet()) {
          map.put(new String(entry.getKey()), SerializationUtil.unserial(clazz, entry.getValue()));
        }
      }
    } catch (UtilException e) {
      throw new CacheException(e);
    } catch (Exception e) {
      throw new CacheException(ErrorCodeDef.CACHE_ERROR_10002, "serial map failed!", e);
    }

    return map;
  }