Skip to content

Commit

Permalink
remove useless READSET from meta-dal and modify the corresponding test
Browse files Browse the repository at this point in the history
  • Loading branch information
NickNYU committed Nov 29, 2018
1 parent 857b4fb commit f48981c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public interface DcService {
List<DcTbl> findAllDcNames();
List<DcTbl> findAllDcBasic();
List<DcTbl> findClusterRelatedDc(String clusterName);
List<DcTbl> findAllDetails(String dcName);
DcTbl findByDcName(String activeDcName);
Map<Long, String> dcNameMap();
List<DcListDcModel> findAllDcsRichInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,6 @@ public List<DcTbl> doQuery() throws DalException {
});
}

@Override
public List<DcTbl> findAllDetails(final String dcName) {
return queryHandler.handleQuery(new DalQuery<List<DcTbl>>() {
@Override
public List<DcTbl> doQuery() throws DalException {
return dao.findDcDetailsByDcName(dcName, DcTblEntity.READSET_FULL_ALL);
}
});
}

@Override
public DcTbl findByDcName(final String dcName) {
return queryHandler.handleQuery(new DalQuery<DcTbl>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
<readset-ref name="FULL"/>
<readset-ref name="FULL" relation-name="redis-info"/>
</readset>
<readset name="FULL_ALL">
<readset-ref name="FULL"/>
<readset-ref name="FULL" relation-name="cluster-info"/>
<readset-ref name="FULL" relation-name="shard-info"/>
<readset-ref name="FULL" relation-name="dc-cluster-info"/>
<readset-ref name="FULL" relation-name="dc-cluster-shard-info"/>
<readset-ref name="FULL" relation-name="redis-info"/>
</readset>
<readset name="NAME">
<member name='dc-name'/>
</readset>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ctrip.xpipe.redis.console.dal;

import com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest;
import com.ctrip.xpipe.redis.console.model.DcClusterShardTbl;
import com.ctrip.xpipe.redis.console.model.DcTbl;
import com.ctrip.xpipe.redis.console.resources.MetaCache;
import com.ctrip.xpipe.redis.console.service.DcClusterShardService;
Expand Down Expand Up @@ -32,76 +33,60 @@
public class DataObjectAssemblyTest extends AbstractConsoleIntegrationTest {
private static final Logger logger = LoggerFactory.getLogger(DataObjectAssemblyTest.class);

@Autowired
private DcMetaService service;

@Autowired
private DcService dcService;

@Autowired
private DcMetaService dcMetaService;

@Autowired
private MetaCache metaCache;

@Autowired
private SentinelService sentinelService;

@Autowired
private KeepercontainerService keepercontainerService;
private DcClusterShardService dcClusterShardService;

@Resource(name = ConsoleContextConfig.GLOBAL_EXECUTOR)
private ExecutorService executor;

private String dcName;
private long dcId;

private int N;

private static final String SQL_PATH = "src/test/resources/DataObjectAssembly-Test.sql";

@Before
public void beforeDataObjectAssemblyTest() throws Exception {
dcName = dcService.dcNameMap().values().iterator().next();
dcId = dcService.dcNameMap().keySet().iterator().next();
N = 20;
startH2Server();
}

@Test
public void testGetDataNotNull() throws InterruptedException, ExecutionException {
CyclicBarrier barrier = new CyclicBarrier(N);
List<Future<List<DcTbl>>> futures = new LinkedList<>();
List<Future<List<DcClusterShardTbl>>> futures = new LinkedList<>();
for(int i = 0; i < N; i ++) {
futures.add(getDCDetails(barrier));
}

for(Future<List<DcTbl>> future : futures) {
List<DcTbl> details = future.get();
for(DcTbl dc : details) {
Assert.assertNotNull(dc);
Assert.assertNotNull(dc.getClusterInfo());
Assert.assertNotNull(dc.getClusterInfo().getClusterName());
Assert.assertNotNull(dc.getClusterInfo().getStatus());
Assert.assertNotNull(dc.getClusterInfo().getDataChangeLastTime());
Assert.assertNotNull(dc.getDcClusterShardInfo());
Assert.assertNotNull(dc.getDcClusterInfo());
Assert.assertNotNull(dc.getDcClusterInfo().getDataChangeLastTime());
Assert.assertNotNull(dc.getRedisInfo());
Assert.assertNotNull(dc.getRedisInfo().getRunId());
Assert.assertNotNull(dc.getRedisInfo().getRedisRole());
Assert.assertNotNull(dc.getRedisInfo().getRedisIp());
Assert.assertNotNull(dc.getShardInfo());
Assert.assertNotNull(dc.getShardInfo().getShardName());
for(Future<List<DcClusterShardTbl>> future : futures) {
List<DcClusterShardTbl> details = future.get();
for(DcClusterShardTbl item : details) {
Assert.assertNotNull(item);
Assert.assertNotNull(item.getClusterInfo());
Assert.assertNotNull(item.getClusterInfo().getClusterName());
Assert.assertNotNull(item.getClusterInfo().getStatus());
Assert.assertNotNull(item.getRedisInfo());
Assert.assertNotNull(item.getRedisInfo().getRunId());
Assert.assertNotNull(item.getRedisInfo().getRedisRole());
Assert.assertNotNull(item.getRedisInfo().getRedisIp());
Assert.assertNotNull(item.getShardInfo());
Assert.assertNotNull(item.getShardInfo().getShardName());
}
}
}


private Future<List<DcTbl>> getDCDetails(CyclicBarrier barrier) {
Future<List<DcTbl>> future_allDetails = executor.submit(new Callable<List<DcTbl>>() {
private Future<List<DcClusterShardTbl>> getDCDetails(CyclicBarrier barrier) {
Future<List<DcClusterShardTbl>> future_allDetails = executor.submit(new Callable<List<DcClusterShardTbl>>() {
@Override
public List<DcTbl> call() throws Exception {
public List<DcClusterShardTbl> call() throws Exception {
barrier.await();
return dcService.findAllDetails(dcName);
return dcClusterShardService.findAllByDcId(dcId);
}
});
return future_allDetails;
Expand Down

0 comments on commit f48981c

Please sign in to comment.