Search in sources :

Example 71 with HostPort

use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.

the class DefaultSentinelMonitorsCheckTest method checkSentinel2.

@Test
public void checkSentinel2() throws Exception {
    when(metaCache.findClusterShardBySentinelMonitor(any())).thenReturn(new Pair<>("cluster", "shard"));
    checker.checkSentinel(new SentinelMeta().setAddress("127.0.0.1:5000,127.0.0.1:5001,127.0.0.1:5002"), new HostPort("127.0.0.1", 5000));
    verify(alertManager, never()).alert(eq(null), eq(null), eq(null), eq(ALERT_TYPE.SENTINEL_MONITOR_INCONSIS), anyString());
    verify(sentinelManager, never()).removeSentinelMonitor(any(), any());
}
Also used : SentinelMeta(com.ctrip.xpipe.redis.core.entity.SentinelMeta) HostPort(com.ctrip.xpipe.endpoint.HostPort) Test(org.junit.Test)

Example 72 with HostPort

use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.

the class DefaultShardMigrationResultTest method testEncodeDecode.

@Test
public void testEncodeDecode() {
    DefaultShardMigrationResult result = new DefaultShardMigrationResult();
    for (ShardMigrationStep step : ShardMigrationStep.values()) {
        result.updateStepResult(step, true, randomString(10));
    }
    result.setNewMaster(new HostPort("127.0.0.1", randomPort()));
    String encode = result.encode();
    ShardMigrationResult decode = DefaultShardMigrationResult.fromEncodeStr(encode);
    logger.info("{}", decode);
    Assert.assertEquals(result, decode);
}
Also used : ShardMigrationStep(com.ctrip.xpipe.redis.console.migration.model.ShardMigrationStep) HostPort(com.ctrip.xpipe.endpoint.HostPort) ShardMigrationResult(com.ctrip.xpipe.redis.console.migration.model.ShardMigrationResult) Test(org.junit.Test) AbstractConsoleTest(com.ctrip.xpipe.redis.console.AbstractConsoleTest)

Example 73 with HostPort

use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.

the class DefaultDelayServiceTest method testPingService.

@Test
@DirtiesContext
public void testPingService() throws IOException {
    Executors.newScheduledThreadPool(1).scheduleAtFixedRate(new Runnable() {

        @Override
        public void run() {
            System.out.println(delayService.getDelay(new HostPort("127.0.0.1", 6379)));
            System.out.println(delayService.getDelay(new HostPort("127.0.0.1", 6389)));
            System.out.println(delayService.getDelay(new HostPort("127.0.0.1", 6369)));
            System.out.println(delayService.getDelay(new HostPort("127.0.0.1", 6359)));
        }
    }, 0, 2, TimeUnit.SECONDS);
    waitForAnyKeyToExit();
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Example 74 with HostPort

use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.

the class AbstractMigrationPublishState method getNewMasters.

public List<InetSocketAddress> getNewMasters() {
    List<InetSocketAddress> result = new LinkedList<>();
    for (MigrationShard migrationShard : getHolder().getMigrationShards()) {
        HostPort newMasterAddress = migrationShard.getNewMasterAddress();
        if (newMasterAddress == null) {
            // may force publish
            logger.warn("[getNewMasters][null master]{}", migrationShard.shardName());
            continue;
        }
        result.add(InetSocketAddress.createUnresolved(newMasterAddress.getHost(), newMasterAddress.getPort()));
    }
    return result;
}
Also used : MigrationShard(com.ctrip.xpipe.redis.console.migration.model.MigrationShard) InetSocketAddress(java.net.InetSocketAddress) HostPort(com.ctrip.xpipe.endpoint.HostPort) LinkedList(java.util.LinkedList)

Example 75 with HostPort

use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.

the class AllKeyMode method test.

@Override
public void test() throws Exception {
    if (slaves.size() > 1) {
        throw new IllegalStateException("all key mode support only one slave!!!");
    }
    HostPort slave = slaves.get(0);
    if (startValueCheck) {
        logger.info("[test][addValueCheck]");
        JedisPool slavePool = getJedisPool(slave.getHost(), slave.getPort(), valueCheckThreadNum * 2, valueCheckThreadNum);
        valueCheck = new DefaultValueCheck(valueCheckThreadNum, slavePool, metricLog);
    } else {
        logger.info("[test][NullValueCheck]");
        valueCheck = new NullValueCheck();
    }
    valueCheck.start();
    super.test();
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort) JedisPool(redis.clients.jedis.JedisPool)

Aggregations

HostPort (com.ctrip.xpipe.endpoint.HostPort)79 Test (org.junit.Test)31 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)7 LinkedList (java.util.LinkedList)7 ALERT_TYPE (com.ctrip.xpipe.redis.console.alert.ALERT_TYPE)6 MasterInfo (com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo)6 AbstractMetaServerTest (com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)6 ClusterShardHostPort (com.ctrip.xpipe.endpoint.ClusterShardHostPort)5 HashSet (java.util.HashSet)5 List (java.util.List)5 Map (java.util.Map)5 RedisConf (com.ctrip.xpipe.redis.console.health.redisconf.RedisConf)4 MasterNotFoundException (com.ctrip.xpipe.redis.console.resources.MasterNotFoundException)4 XpipeMetaManager (com.ctrip.xpipe.redis.core.meta.XpipeMetaManager)4 Set (java.util.Set)4 AbstractConsoleTest (com.ctrip.xpipe.redis.console.AbstractConsoleTest)3 AlertEntity (com.ctrip.xpipe.redis.console.alert.AlertEntity)3 AlertManager (com.ctrip.xpipe.redis.console.alert.AlertManager)3 DefaultRedisSessionManager (com.ctrip.xpipe.redis.console.health.DefaultRedisSessionManager)3 ClusterListClusterModel (com.ctrip.xpipe.redis.console.model.consoleportal.ClusterListClusterModel)3