@Override public Boolean batchRemove(final List<String> ids, final String appName) { if (CollectionUtils.isEmpty(ids) || StringUtils.isBlank(appName)) { return Boolean.FALSE; } final String rootPathPrefix = RepositoryPathUtils.buildZookeeperPathPrefix(appName); ids.stream().map(id -> { try { final String path = RepositoryPathUtils.buildZookeeperRootPath(rootPathPrefix, id); byte[] content = zooKeeper.getData(path, false, new Stat()); final CoordinatorRepositoryAdapter adapter = objectSerializer.deSerialize(content, CoordinatorRepositoryAdapter.class); zooKeeper.delete(path, adapter.getVersion()); return 1; } catch (Exception e) { e.printStackTrace(); return -1; } }).count(); return Boolean.TRUE; }
@Override public void init(final String modelName, final HmilyConfig hmilyConfig) { rootPathPrefix = RepositoryPathUtils.buildZookeeperPathPrefix(modelName); try { connect(hmilyConfig.getHmilyZookeeperConfig()); } catch (Exception e) { LogUtil.error(LOGGER, "zookeeper init error please check you config:{}", e::getMessage); throw new HmilyRuntimeException(e.getMessage()); } }
@Override public Boolean updateRetry(final String id, final Integer retry, final String appName) { if (StringUtils.isBlank(id) || StringUtils.isBlank(appName) || Objects.isNull(retry)) { return Boolean.FALSE; } final String rootPathPrefix = RepositoryPathUtils.buildZookeeperPathPrefix(appName); final String path = RepositoryPathUtils.buildZookeeperRootPath(rootPathPrefix, id); try { byte[] content = zooKeeper.getData(path, false, new Stat()); final CoordinatorRepositoryAdapter adapter = objectSerializer.deSerialize(content, CoordinatorRepositoryAdapter.class); adapter.setLastTime(DateUtils.getDateYYYY()); adapter.setRetriedCount(retry); zooKeeper.create(path, objectSerializer.serialize(adapter), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); return Boolean.TRUE; } catch (Exception e) { e.printStackTrace(); } return Boolean.FALSE; }
final int pageSize = query.getPageParameter().getPageSize(); int start = (currentPage - 1) * pageSize; final String rootPath = RepositoryPathUtils.buildZookeeperPathPrefix(query.getApplicationName()); List<String> zNodePaths; List<HmilyCompensationVO> voList;