Search in sources :

Example 11 with DcTbl

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;
}
Also used : DcTbl(com.ctrip.xpipe.redis.console.model.DcTbl) OrganizationTbl(com.ctrip.xpipe.redis.console.model.OrganizationTbl)

Example 12 with DcTbl

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());
}
Also used : MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) ClusterTbl(com.ctrip.xpipe.redis.console.model.ClusterTbl) MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) ShardTbl(com.ctrip.xpipe.redis.console.model.ShardTbl) LinkedList(java.util.LinkedList) Answer(org.mockito.stubbing.Answer) DcTbl(com.ctrip.xpipe.redis.console.model.DcTbl) InvocationOnMock(org.mockito.invocation.InvocationOnMock)

Example 13 with DcTbl

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);
}
Also used : DcTbl(com.ctrip.xpipe.redis.console.model.DcTbl) ClusterMeta(com.ctrip.xpipe.redis.core.entity.ClusterMeta) ResourceAccessException(org.springframework.web.client.ResourceAccessException) Before(org.junit.Before)

Aggregations

DcTbl (com.ctrip.xpipe.redis.console.model.DcTbl)13 MigrationClusterTbl (com.ctrip.xpipe.redis.console.model.MigrationClusterTbl)5 Test (org.junit.Test)5 ClusterTbl (com.ctrip.xpipe.redis.console.model.ClusterTbl)4 AbstractConsoleTest (com.ctrip.xpipe.redis.console.AbstractConsoleTest)3 Before (org.junit.Before)3 DefaultMigrationCluster (com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationCluster)2 DefaultMigrationShard (com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationShard)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 ParallelCommandChain (com.ctrip.xpipe.command.ParallelCommandChain)1 HostPort (com.ctrip.xpipe.endpoint.HostPort)1 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)1 ClusterStatus (com.ctrip.xpipe.redis.console.migration.status.ClusterStatus)1 DcClusterTbl (com.ctrip.xpipe.redis.console.model.DcClusterTbl)1 OrganizationTbl (com.ctrip.xpipe.redis.console.model.OrganizationTbl)1 SentinelModel (com.ctrip.xpipe.redis.console.model.SentinelModel)1 SetinelTbl (com.ctrip.xpipe.redis.console.model.SetinelTbl)1 ShardTbl (com.ctrip.xpipe.redis.console.model.ShardTbl)1 DcMetaBuilder (com.ctrip.xpipe.redis.console.service.vo.DcMetaBuilder)1