@Test public void listByPage() throws Exception { RecoverTransactionQuery query = new RecoverTransactionQuery(); query.setApplicationName("alipay-service"); PageParameter pageParameter = new PageParameter(1,8); query.setPageParameter(pageParameter); final CommonPager<TransactionRecoverVO> voCommonPager = recoverTransactionService.listByPage(query); }
@Override public CommonPager<TransactionRecoverVO> listByPage(final RecoverTransactionQuery query) { CommonPager<TransactionRecoverVO> voCommonPager = new CommonPager<>(); final int currentPage = query.getPageParameter().getCurrentPage(); final int pageSize = query.getPageParameter().getPageSize(); int start = (currentPage - 1) * pageSize; final String rootPath = RepositoryPathUtils.buildZookeeperPath(query.getApplicationName()); List<String> zNodePaths; List<TransactionRecoverVO> voList; int totalCount; try { if (StringUtils.isBlank(query.getTxGroupId()) && Objects.nonNull(query.getRetry())) { zNodePaths = zooKeeper.getChildren(rootPath, false); final List<TransactionRecoverVO> all = findAll(zNodePaths, rootPath); final List<TransactionRecoverVO> collect = all.stream() .filter(vo -> vo.getRetriedCount() < query.getRetry()) .collect(Collectors.toList()); totalCount = collect.size(); voList = collect.stream().skip(start).limit(pageSize).collect(Collectors.toList()); } else if (StringUtils.isNoneBlank(query.getTxGroupId()) && Objects.isNull(query.getRetry())) { zNodePaths = Lists.newArrayList(query.getTxGroupId()); totalCount = zNodePaths.size(); voList = findAll(zNodePaths, rootPath); } else if (StringUtils.isNoneBlank(query.getTxGroupId()) && Objects.nonNull(query.getRetry())) { zNodePaths = Lists.newArrayList(query.getTxGroupId()); totalCount = zNodePaths.size(); voList = findAll(zNodePaths, rootPath) .stream() .filter(vo -> vo.getRetriedCount() < query.getRetry()) .collect(Collectors.toList()); } else { zNodePaths = zooKeeper.getChildren(rootPath, false); totalCount = zNodePaths.size(); voList = findByPage(zNodePaths, rootPath, start, pageSize); } voCommonPager.setPage(PageHelper.buildPage(query.getPageParameter(), totalCount)); voCommonPager.setDataList(voList); } catch (Exception e) { e.printStackTrace(); } return voCommonPager; }
ZookeeperRecoverTransactionServiceImpl implements RecoverTransactionService { @Override public CommonPager<TransactionRecoverVO> listByPage(final RecoverTransactionQuery query) { CommonPager<TransactionRecoverVO> voCommonPager = new CommonPager<>(); final int currentPage = query.getPageParameter().getCurrentPage(); final int pageSize = query.getPageParameter().getPageSize(); int start = (currentPage - 1) * pageSize; final String rootPath = RepositoryPathUtils.buildZookeeperPath(query.getApplicationName()); List<String> zNodePaths; List<TransactionRecoverVO> voList; int totalCount; try { if (StringUtils.isBlank(query.getTxGroupId()) && Objects.nonNull(query.getRetry())) { zNodePaths = zooKeeper.getChildren(rootPath, false); final List<TransactionRecoverVO> all = findAll(zNodePaths, rootPath); final List<TransactionRecoverVO> collect = all.stream() .filter(vo -> vo.getRetriedCount() < query.getRetry()) .collect(Collectors.toList()); totalCount = collect.size(); voList = collect.stream().skip(start).limit(pageSize).collect(Collectors.toList()); } else if (StringUtils.isNoneBlank(query.getTxGroupId()) && Objects.isNull(query.getRetry())) { zNodePaths = Lists.newArrayList(query.getTxGroupId()); totalCount = zNodePaths.size(); voList = findAll(zNodePaths, rootPath); } else if (StringUtils.isNoneBlank(query.getTxGroupId()) && Objects.nonNull(query.getRetry())) { zNodePaths = Lists.newArrayList(query.getTxGroupId()); totalCount = zNodePaths.size(); voList = findAll(zNodePaths, rootPath) .stream() .filter(vo -> vo.getRetriedCount() < query.getRetry()) .collect(Collectors.toList()); } else { zNodePaths = zooKeeper.getChildren(rootPath, false); totalCount = zNodePaths.size(); voList = findByPage(zNodePaths, rootPath, start, pageSize); } voCommonPager.setPage(PageHelper.buildPage(query.getPageParameter(), totalCount)); voCommonPager.setDataList(voList); } catch (Exception e) { e.printStackTrace(); } return voCommonPager; } }
ZookeeperRecoverTransactionServiceImpl implements RecoverTransactionService { @Override public CommonPager<TransactionRecoverVO> listByPage(final RecoverTransactionQuery query) { CommonPager<TransactionRecoverVO> voCommonPager = new CommonPager<>(); final int currentPage = query.getPageParameter().getCurrentPage(); final int pageSize = query.getPageParameter().getPageSize(); int start = (currentPage - 1) * pageSize; final String rootPath = RepositoryPathUtils.buildZookeeperPath(query.getApplicationName()); List<String> zNodePaths; List<TransactionRecoverVO> voList; int totalCount; try { if (StringUtils.isBlank(query.getTxGroupId()) && Objects.nonNull(query.getRetry())) { zNodePaths = zooKeeper.getChildren(rootPath, false); final List<TransactionRecoverVO> all = findAll(zNodePaths, rootPath); final List<TransactionRecoverVO> collect = all.stream() .filter(vo -> vo.getRetriedCount() < query.getRetry()) .collect(Collectors.toList()); totalCount = collect.size(); voList = collect.stream().skip(start).limit(pageSize).collect(Collectors.toList()); } else if (StringUtils.isNoneBlank(query.getTxGroupId()) && Objects.isNull(query.getRetry())) { zNodePaths = Lists.newArrayList(query.getTxGroupId()); totalCount = zNodePaths.size(); voList = findAll(zNodePaths, rootPath); } else if (StringUtils.isNoneBlank(query.getTxGroupId()) && Objects.nonNull(query.getRetry())) { zNodePaths = Lists.newArrayList(query.getTxGroupId()); totalCount = zNodePaths.size(); voList = findAll(zNodePaths, rootPath) .stream() .filter(vo -> vo.getRetriedCount() < query.getRetry()) .collect(Collectors.toList()); } else { zNodePaths = zooKeeper.getChildren(rootPath, false); totalCount = zNodePaths.size(); voList = findByPage(zNodePaths, rootPath, start, pageSize); } voCommonPager.setPage(PageHelper.buildPage(query.getPageParameter(), totalCount)); voCommonPager.setDataList(voList); } catch (Exception e) { e.printStackTrace(); } return voCommonPager; } ZookeeperRecoverTransactionServiceImpl(final ZooKeeper zooKeeper, final ObjectSerializer objectSerializer); }
ZookeeperRecoverTransactionServiceImpl implements RecoverTransactionService { @Override public CommonPager<TransactionRecoverVO> listByPage(final RecoverTransactionQuery query) { CommonPager<TransactionRecoverVO> voCommonPager = new CommonPager<>(); final int currentPage = query.getPageParameter().getCurrentPage(); final int pageSize = query.getPageParameter().getPageSize(); int start = (currentPage - 1) * pageSize; final String rootPath = RepositoryPathUtils.buildZookeeperPath(query.getApplicationName()); List<String> zNodePaths; List<TransactionRecoverVO> voList; int totalCount; try { if (StringUtils.isBlank(query.getTxGroupId()) && Objects.nonNull(query.getRetry())) { zNodePaths = zooKeeper.getChildren(rootPath, false); final List<TransactionRecoverVO> all = findAll(zNodePaths, rootPath); final List<TransactionRecoverVO> collect = all.stream() .filter(vo -> vo.getRetriedCount() < query.getRetry()) .collect(Collectors.toList()); totalCount = collect.size(); voList = collect.stream().skip(start).limit(pageSize).collect(Collectors.toList()); } else if (StringUtils.isNoneBlank(query.getTxGroupId()) && Objects.isNull(query.getRetry())) { zNodePaths = Lists.newArrayList(query.getTxGroupId()); totalCount = zNodePaths.size(); voList = findAll(zNodePaths, rootPath); } else if (StringUtils.isNoneBlank(query.getTxGroupId()) && Objects.nonNull(query.getRetry())) { zNodePaths = Lists.newArrayList(query.getTxGroupId()); totalCount = zNodePaths.size(); voList = findAll(zNodePaths, rootPath) .stream() .filter(vo -> vo.getRetriedCount() < query.getRetry()) .collect(Collectors.toList()); } else { zNodePaths = zooKeeper.getChildren(rootPath, false); totalCount = zNodePaths.size(); voList = findByPage(zNodePaths, rootPath, start, pageSize); } voCommonPager.setPage(PageHelper.buildPage(query.getPageParameter(), totalCount)); voCommonPager.setDataList(voList); } catch (Exception e) { e.printStackTrace(); } return voCommonPager; } ZookeeperRecoverTransactionServiceImpl(final ZooKeeper zooKeeper, final ObjectSerializer objectSerializer); @Override CommonPager<TransactionRecoverVO> listByPage(final RecoverTransactionQuery query); @Override Boolean batchRemove(final List<String> ids, final String applicationName); @Override Boolean updateRetry(final String id, final Integer retry, final String applicationName); }
ZookeeperRecoverTransactionServiceImpl implements RecoverTransactionService { @Override public CommonPager<TransactionRecoverVO> listByPage(final RecoverTransactionQuery query) { CommonPager<TransactionRecoverVO> voCommonPager = new CommonPager<>(); final int currentPage = query.getPageParameter().getCurrentPage(); final int pageSize = query.getPageParameter().getPageSize(); int start = (currentPage - 1) * pageSize; final String rootPath = RepositoryPathUtils.buildZookeeperPath(query.getApplicationName()); List<String> zNodePaths; List<TransactionRecoverVO> voList; int totalCount; try { if (StringUtils.isBlank(query.getTxGroupId()) && Objects.nonNull(query.getRetry())) { zNodePaths = zooKeeper.getChildren(rootPath, false); final List<TransactionRecoverVO> all = findAll(zNodePaths, rootPath); final List<TransactionRecoverVO> collect = all.stream() .filter(vo -> vo.getRetriedCount() < query.getRetry()) .collect(Collectors.toList()); totalCount = collect.size(); voList = collect.stream().skip(start).limit(pageSize).collect(Collectors.toList()); } else if (StringUtils.isNoneBlank(query.getTxGroupId()) && Objects.isNull(query.getRetry())) { zNodePaths = Lists.newArrayList(query.getTxGroupId()); totalCount = zNodePaths.size(); voList = findAll(zNodePaths, rootPath); } else if (StringUtils.isNoneBlank(query.getTxGroupId()) && Objects.nonNull(query.getRetry())) { zNodePaths = Lists.newArrayList(query.getTxGroupId()); totalCount = zNodePaths.size(); voList = findAll(zNodePaths, rootPath) .stream() .filter(vo -> vo.getRetriedCount() < query.getRetry()) .collect(Collectors.toList()); } else { zNodePaths = zooKeeper.getChildren(rootPath, false); totalCount = zNodePaths.size(); voList = findByPage(zNodePaths, rootPath, start, pageSize); } voCommonPager.setPage(PageHelper.buildPage(query.getPageParameter(), totalCount)); voCommonPager.setDataList(voList); } catch (Exception e) { e.printStackTrace(); } return voCommonPager; } ZookeeperRecoverTransactionServiceImpl(final ZooKeeper zooKeeper, final ObjectSerializer objectSerializer); @Override CommonPager<TransactionRecoverVO> listByPage(final RecoverTransactionQuery query); @Override Boolean batchRemove(final List<String> ids, final String applicationName); @Override Boolean updateRetry(final String id, final Integer retry, final String applicationName);  }