use of com.ctrip.xpipe.redis.console.model.DcTbl in project x-pipe by ctripcorp.
the class ClusterCreateInfo method fromClusterTbl.
public static ClusterCreateInfo fromClusterTbl(ClusterTbl clusterTbl, DcService dcService) {
ClusterCreateInfo clusterCreateInfo = new ClusterCreateInfo();
clusterCreateInfo.setDesc(clusterTbl.getClusterDescription());
clusterCreateInfo.setClusterName(clusterTbl.getClusterName());
OrganizationTbl organizationTbl = clusterTbl.getOrganizationInfo();
clusterCreateInfo.setOrganizationId(organizationTbl != null ? organizationTbl.getOrgId() : 0L);
clusterCreateInfo.setClusterAdminEmails(clusterTbl.getClusterAdminEmails());
List<DcTbl> clusterRelatedDc = dcService.findClusterRelatedDc(clusterTbl.getClusterName());
clusterRelatedDc.forEach(dcTbl -> {
if (dcTbl.getId() == clusterTbl.getActivedcId()) {
clusterCreateInfo.addFirstDc(dcTbl.getDcName());
} else {
clusterCreateInfo.addDc(dcTbl.getDcName());
}
});
return clusterCreateInfo;
}
use of com.ctrip.xpipe.redis.console.model.DcTbl in project x-pipe by ctripcorp.
the class MigrationStatTest method prepareData.
private void prepareData() {
mockedMigrationCluster = (new MigrationClusterTbl()).setId(1).setEventId(1).setClusterId(1).setDestinationDcId(2).setStatus(MigrationStatus.Initiated.toString());
ClusterTbl clusterTbl = new ClusterTbl().setId(1).setClusterName("test-cluster").setActivedcId(1).setStatus(ClusterStatus.Lock.toString());
when(mockedClusterService.find(1)).thenReturn(clusterTbl);
List<ShardTbl> shards = new LinkedList<>();
shards.add((new ShardTbl()).setId(1).setClusterId(1).setShardName("test-shard"));
when(mockedShardService.findAllByClusterName("test-cluster")).thenReturn(shards);
List<DcTbl> dcs = new LinkedList<>();
dcs.add((new DcTbl()).setId(1).setDcName("ADC"));
dcs.add((new DcTbl()).setId(2).setDcName("BDC"));
when(mockedDcService.findClusterRelatedDc("test-cluster")).thenReturn(dcs);
when(mockedClusterService.find(anyString())).thenReturn(clusterTbl);
when(mockedClusterService.find(anyInt())).thenReturn(clusterTbl);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
clusterTbl.setStatus(((ClusterStatus) invocation.getArguments()[1]).toString());
return null;
}
}).when(mockedClusterService).updateStatusById(anyInt(), any());
}
use of com.ctrip.xpipe.redis.console.model.DcTbl 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);
}
Aggregations