Search in sources :

Example 1 with HostPort

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

the class XPipeStabilityTest method statbilityTest.

@Test
public void statbilityTest() throws Exception {
    String mode = System.getProperty("mode", "all");
    Cat.logEvent("statbilityTest", "begin");
    HostPort master = new HostPort(IpUtils.parseSingle(masterAddress));
    List<HostPort> slaves = new LinkedList<>();
    IpUtils.parse(slaveAddress).forEach(address -> slaves.add(new HostPort(address)));
    if (mode.equalsIgnoreCase("all")) {
        testMode = new AllKeyMode(master, slaves, producerThreadNum, producerIntervalMicro, msgSize, maxKeys);
    } else {
        testMode = new PubSubMode(master, slaves, producerThreadNum, producerIntervalMicro, msgSize, maxKeys);
    }
    logger.info("{}", testMode);
    testMode.test();
    TimeUnit.DAYS.sleep(runDays);
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 2 with HostPort

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

the class DefaultSentinelManager method getMasterOfMonitor.

@Override
public HostPort getMasterOfMonitor(Sentinel sentinel, String sentinelMonitorName) {
    SimpleObjectPool<NettyClient> clientPool = keyedClientPool.getKeyPool(new InetSocketAddress(sentinel.getIp(), sentinel.getPort()));
    AbstractSentinelCommand.SentinelMaster sentinelMaster = new AbstractSentinelCommand.SentinelMaster(clientPool, scheduled, sentinelMonitorName);
    sentinelMaster.logResponse(false);
    HostPort result = null;
    try {
        result = sentinelMaster.execute().get();
        logger.info("[getMasterOfMonitor]getMasterOfMonitor {} from {} : {}", sentinelMonitorName, sentinel, result);
    } catch (Exception e) {
        logger.error("[getMasterOfMonitor] {} from {} : {}", sentinelMonitorName, sentinel, e.getMessage());
    }
    return result;
}
Also used : NettyClient(com.ctrip.xpipe.netty.commands.NettyClient) InetSocketAddress(java.net.InetSocketAddress) HostPort(com.ctrip.xpipe.endpoint.HostPort) AbstractSentinelCommand(com.ctrip.xpipe.redis.core.protocal.cmd.AbstractSentinelCommand)

Example 3 with HostPort

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

the class DefaultMetaCache method findMasterInSameShard.

@Override
public HostPort findMasterInSameShard(HostPort hostPort) {
    XpipeMetaManager xpipeMetaManager = meta.getValue();
    XpipeMetaManager.MetaDesc metaDesc = xpipeMetaManager.findMetaDesc(hostPort);
    if (metaDesc == null) {
        throw new IllegalStateException("unfound shard for instance:" + hostPort);
    }
    String clusterName = metaDesc.getClusterId();
    String shardName = metaDesc.getShardId();
    Pair<String, RedisMeta> redisMaster = xpipeMetaManager.getRedisMaster(clusterName, shardName);
    // could be null if no master in a shard
    if (redisMaster == null) {
        return null;
    }
    RedisMeta redisMeta = redisMaster.getValue();
    return new HostPort(redisMeta.getIp(), redisMeta.getPort());
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort) XpipeMetaManager(com.ctrip.xpipe.redis.core.meta.XpipeMetaManager) DefaultXpipeMetaManager(com.ctrip.xpipe.redis.core.meta.impl.DefaultXpipeMetaManager)

Example 4 with HostPort

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

the class DefaultMetaCache method allKeepers.

@Override
public Set<HostPort> allKeepers() {
    Set<HostPort> result = new HashSet<>();
    XpipeMeta xpipeMeta = getXpipeMeta();
    xpipeMeta.getDcs().forEach((dcName, dcMeta) -> {
        dcMeta.getClusters().forEach((clusterName, clusterMeta) -> {
            clusterMeta.getShards().forEach((shardName, shardMeta) -> {
                shardMeta.getKeepers().forEach(keeperMeta -> {
                    result.add(new HostPort(keeperMeta.getIp(), keeperMeta.getPort()));
                });
            });
        });
    });
    return result;
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort)

Example 5 with HostPort

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

the class DefaultMetaCache method findMaster.

@Override
public HostPort findMaster(String clusterId, String shardId) throws MasterNotFoundException {
    XpipeMetaManager xpipeMetaManager = meta.getValue();
    Pair<String, RedisMeta> redisMaster = xpipeMetaManager.getRedisMaster(clusterId, shardId);
    if (redisMaster == null) {
        throw new MasterNotFoundException(clusterId, shardId);
    }
    return new HostPort(redisMaster.getValue().getIp(), redisMaster.getValue().getPort());
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort) XpipeMetaManager(com.ctrip.xpipe.redis.core.meta.XpipeMetaManager) DefaultXpipeMetaManager(com.ctrip.xpipe.redis.core.meta.impl.DefaultXpipeMetaManager)

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