use of com.ctrip.xpipe.redis.core.entity.ClusterMeta in project x-pipe by ctripcorp.
the class DcMetaComparator method compare.
public void compare() {
Triple<Set<String>, Set<String>, Set<String>> result = getDiff(current.getClusters().keySet(), future.getClusters().keySet());
Set<String> addedClusterIds = result.getFirst();
Set<String> intersectionClusterIds = result.getMiddle();
Set<String> deletedClusterIds = result.getLast();
for (String clusterId : addedClusterIds) {
added.add(future.findCluster(clusterId));
}
for (String clusterId : deletedClusterIds) {
removed.add(current.findCluster(clusterId));
}
for (String clusterId : intersectionClusterIds) {
ClusterMeta currentMeta = current.findCluster(clusterId);
ClusterMeta futureMeta = future.findCluster(clusterId);
if (!reflectionEquals(currentMeta, futureMeta)) {
ClusterMetaComparator clusterMetaComparator = new ClusterMetaComparator(currentMeta, futureMeta);
clusterMetaComparator.compare();
modified.add(clusterMetaComparator);
}
}
}
use of com.ctrip.xpipe.redis.core.entity.ClusterMeta in project x-pipe by ctripcorp.
the class ClusterMetaModifiedNotifierTest method initMockData.
@Before
public void initMockData() {
dcName = "mockedDc";
mockedDcTbl = new DcTbl().setDcName(dcName);
clusterName = "mockedClusterName";
mockedClusterMeta = new ClusterMeta().setId(clusterName).setActiveDc(dcName);
when(config.getConsoleNotifyRetryTimes()).thenReturn(retryTimes - 1);
when(config.getConsoleNotifyRetryInterval()).thenReturn(10);
when(config.getConsoleNotifyThreads()).thenReturn(20);
notifier.postConstruct();
when(metaServerConsoleServiceManagerWrapper.get(dcName)).thenReturn(mockedMetaServerConsoleService);
doThrow(new ResourceAccessException("test")).when(mockedMetaServerConsoleService).clusterAdded(clusterName, mockedClusterMeta);
doThrow(new ResourceAccessException("test")).when(mockedMetaServerConsoleService).clusterDeleted(clusterName);
doThrow(new ResourceAccessException("test")).when(mockedMetaServerConsoleService).clusterModified(clusterName, mockedClusterMeta);
when(clusterMetaService.getClusterMeta(dcName, clusterName)).thenReturn(mockedClusterMeta);
}
use of com.ctrip.xpipe.redis.core.entity.ClusterMeta in project x-pipe by ctripcorp.
the class ClusterMetaServiceTest method testFindMigratingClusterMeta.
@Test
@DirtiesContext
public void testFindMigratingClusterMeta() {
ClusterTbl cluster = clusterService.find(clusterName2);
Assert.assertEquals(ClusterStatus.Migrating.toString(), cluster.getStatus());
ClusterMeta clusterMetaA = clusterMetaService.getClusterMeta(dcA, clusterName2);
ClusterMeta clusterMetaB = clusterMetaService.getClusterMeta(dcB, clusterName2);
Assert.assertEquals(dcA, clusterMetaA.getActiveDc());
Assert.assertEquals(dcB, clusterMetaB.getActiveDc());
}
use of com.ctrip.xpipe.redis.core.entity.ClusterMeta in project x-pipe by ctripcorp.
the class ClusterMetaServiceTest method testFindNonMigratingClusterMeta.
@Test
@DirtiesContext
public void testFindNonMigratingClusterMeta() {
ClusterMeta clusterMetaA = clusterMetaService.getClusterMeta(dcA, clusterName1);
ClusterMeta clusterMetaB = clusterMetaService.getClusterMeta(dcB, clusterName1);
ClusterTbl cluster = clusterService.find(clusterName1);
Assert.assertEquals(ClusterStatus.Normal.toString(), cluster.getStatus());
Assert.assertNotNull(clusterMetaA);
Assert.assertNotNull(clusterMetaB);
Assert.assertEquals(dcA, clusterMetaA.getActiveDc());
Assert.assertEquals(dcA, clusterMetaB.getActiveDc());
}
use of com.ctrip.xpipe.redis.core.entity.ClusterMeta in project x-pipe by ctripcorp.
the class DcMetaBuilderTest method getOrCreateShardMeta.
@Test
public void getOrCreateShardMeta() throws Exception {
DcClusterShardTbl dcClusterShard = dcClusterShards.get(0);
builder.getOrCreateClusterMeta(dcClusterShards.get(0).getClusterInfo());
ClusterMeta clusterMeta = dcMeta.getClusters().get(dcClusterShard.getClusterInfo().getClusterName());
logger.info("{}", dcClusterShard.getShardInfo());
builder.getOrCreateShardMeta(clusterMeta.getId(), dcClusterShard.getShardInfo(), dcClusterShard.getSetinelId());
String clusterId = dcClusterShard.getClusterInfo().getClusterName(), shardId = dcClusterShard.getShardInfo().getShardName();
ShardMeta shardMeta = dcMeta.findCluster(clusterId).findShard(shardId);
Assert.assertNotNull(shardMeta);
logger.info("{}", shardMeta);
}
Aggregations