Search in sources :

Example 21 with HostPort

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

the class DefaultPingServiceTest method testPingService.

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

        @Override
        public void run() {
            System.out.println(pingService.isRedisAlive(new HostPort("127.0.0.1", 6379)));
        }
    }, 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 22 with HostPort

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

the class SenderManagerTest method sendAlerts.

@Test
public void sendAlerts() throws Exception {
    HostPort hostPort = new HostPort("192.168.1.10", 6379);
    Map<ALERT_TYPE, Set<AlertEntity>> alerts = new HashMap<>();
    alerts.put(ALERT_TYPE.CLIENT_INCONSIS, Collections.singleton(new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.CLIENT_INCONSIS)));
    alerts.put(ALERT_TYPE.XREDIS_VERSION_NOT_VALID, Collections.singleton(new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.XREDIS_VERSION_NOT_VALID)));
    alerts.put(ALERT_TYPE.QUORUM_DOWN_FAIL, Collections.singleton(new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.QUORUM_DOWN_FAIL)));
    alerts.put(ALERT_TYPE.SENTINEL_RESET, Collections.singleton(new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.SENTINEL_RESET)));
    alerts.put(ALERT_TYPE.REDIS_CONF_REWRITE_FAILURE, Collections.singleton(new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.REDIS_CONF_REWRITE_FAILURE)));
    alerts.put(ALERT_TYPE.REDIS_REPL_DISKLESS_SYNC_ERROR, Collections.singleton(new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.REDIS_REPL_DISKLESS_SYNC_ERROR)));
    alerts.put(ALERT_TYPE.MIGRATION_MANY_UNFINISHED, Collections.singleton(new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.MIGRATION_MANY_UNFINISHED)));
    logger.info("{}", alerts);
    senderManager.sendAlerts(alerts);
}
Also used : ConcurrentSet(io.netty.util.internal.ConcurrentSet) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HostPort(com.ctrip.xpipe.endpoint.HostPort) AlertEntity(com.ctrip.xpipe.redis.console.alert.AlertEntity) ALERT_TYPE(com.ctrip.xpipe.redis.console.alert.ALERT_TYPE) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 23 with HostPort

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

the class DefaultPrimaryDcPrepareToChange method deprepare.

@Override
public MetaServerConsoleService.PreviousPrimaryDcMessage deprepare(String clusterId, String shardId) {
    logger.info("[deprepare]{}, {}", clusterId, shardId);
    MetaServerConsoleService.PreviousPrimaryDcMessage message = new MetaServerConsoleService.PreviousPrimaryDcMessage();
    ExecutionLog executionLog = new ExecutionLog(String.format("meta server:%s", currentClusterServer.getClusterInfo()));
    Pair<String, Integer> keeperMaster = currentMetaManager.getKeeperMaster(clusterId, shardId);
    message.setMasterAddr(new HostPort(keeperMaster.getKey(), keeperMaster.getValue()));
    executionLog.info("[deprepare]" + keeperMaster);
    makeMasterReadOnly(clusterId, shardId, keeperMaster, false, executionLog);
    addSentinel(clusterId, shardId, executionLog);
    message.setMessage(executionLog.getLog());
    return message;
}
Also used : ExecutionLog(com.ctrip.xpipe.redis.meta.server.dcchange.ExecutionLog) MetaServerConsoleService(com.ctrip.xpipe.redis.core.metaserver.MetaServerConsoleService) HostPort(com.ctrip.xpipe.endpoint.HostPort)

Example 24 with HostPort

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

the class SentinelUpdateController method convert2SentinelTbl.

@VisibleForTesting
protected SetinelTbl convert2SentinelTbl(SentinelModel sentinelModel) {
    StringBuilder sb = new StringBuilder();
    for (HostPort hostPort : sentinelModel.getSentinels()) {
        sb.append(hostPort.getHost()).append(':').append(hostPort.getPort()).append(',');
    }
    String sentinels = sb.deleteCharAt(sb.length() - 1).toString();
    SetinelTbl proto = new SetinelTbl();
    proto.setSetinelAddress(sentinels);
    proto.setDeleted(false);
    proto.setSetinelDescription(sentinelModel.getDesc());
    proto.setDcId(dcService.find(sentinelModel.getDcName()).getId());
    return proto;
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort) SetinelTbl(com.ctrip.xpipe.redis.console.model.SetinelTbl) VisibleForTesting(com.ctrip.xpipe.utils.VisibleForTesting)

Example 25 with HostPort

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

the class DefaultDelayMonitor method convertToSampleResult.

private DelaySampleResult convertToSampleResult(Sample<InstanceDelayResult> sample) {
    BaseSamplePlan<InstanceDelayResult> plan = sample.getSamplePlan();
    DelaySampleResult sampleResult = new DelaySampleResult(sample.getStartTime(), plan.getClusterId(), plan.getShardId());
    for (Entry<HostPort, InstanceDelayResult> entry : plan.getHostPort2SampleResult().entrySet()) {
        HostPort hostPort = entry.getKey();
        InstanceDelayResult delay = entry.getValue();
        long delayNanos = SAMPLE_LOST_AND_NO_PONG;
        if (delay.isDone()) {
            delayNanos = delay.calculateDelay(sample.getStartNanoTime());
        } else {
            if (pingSvc.isRedisAlive(hostPort)) {
                delayNanos = SAMPLE_LOST_BUT_PONG;
            }
        }
        if (delay.isMaster()) {
            sampleResult.setMasterDelayNanos(hostPort, delayNanos);
        } else {
            sampleResult.addSlaveDelayNanos(hostPort, delayNanos);
        }
    }
    return sampleResult;
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort)

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