Search in sources :

Example 56 with HostPort

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

the class DefaultPingMonitor method converToSampleResult.

private PingSampleResult converToSampleResult(Sample<InstancePingResult> sample) {
    BaseSamplePlan<InstancePingResult> plan = sample.getSamplePlan();
    PingSampleResult result = new PingSampleResult(plan.getClusterId(), plan.getShardId());
    for (Entry<HostPort, InstancePingResult> entry : sample.getSamplePlan().getHostPort2SampleResult().entrySet()) {
        HostPort hostPort = entry.getKey();
        result.addPong(hostPort, entry.getValue());
    }
    return result;
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort)

Example 57 with HostPort

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

the class DefaultRedisConfManager method findOrCreateConfig.

@Override
public RedisConf findOrCreateConfig(String host, int port) {
    HostPort hostPort = new HostPort(host, port);
    RedisConf conf = configs.get(hostPort);
    if (conf == null) {
        synchronized (this) {
            conf = configs.get(hostPort);
            if (conf == null) {
                conf = buildRedisConf(hostPort);
                configs.put(hostPort, conf);
            }
        }
    }
    return conf;
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort)

Example 58 with HostPort

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

the class ConfigRewriteMonitor method sampleConfigRewrie.

private void sampleConfigRewrie(long startNanoTime, BaseSamplePlan<InstanceRedisConfResult> plan) {
    for (Map.Entry<HostPort, InstanceRedisConfResult> entry : plan.getHostPort2SampleResult().entrySet()) {
        HostPort hostPort = entry.getKey();
        try {
            findRedisSession(hostPort).configRewrite((result, th) -> {
                if (th == null) {
                    log.info("[sampleConfigRewrie][good]{}, {}", hostPort, result);
                    goodRedises.add(hostPort);
                    addInstanceSuccess(startNanoTime, hostPort, null);
                } else {
                    log.info("[sampleConfigRewrie][bad]" + hostPort, th);
                    addInstanceFail(startNanoTime, hostPort.getHost(), hostPort.getPort(), new ConfigRewriteFail("fail:" + hostPort, th));
                }
            });
        } catch (Exception e) {
            addInstanceFail(startNanoTime, hostPort.getHost(), hostPort.getPort(), e);
        }
    }
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort) Map(java.util.Map)

Example 59 with HostPort

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

the class IpUtils method parseAsHostPorts.

public static List<HostPort> parseAsHostPorts(String addressDesc) {
    if (addressDesc == null) {
        throw new IllegalArgumentException("addressDesc null");
    }
    if (StringUtil.isEmpty(addressDesc)) {
        return new LinkedList<>();
    }
    List<HostPort> result = new LinkedList<>();
    String[] addresses = addressDesc.split("\\s*,\\s*");
    for (String address : addresses) {
        try {
            HostPort hostPort = parseSingleAsHostPort(address);
            result.add(hostPort);
        } catch (Exception e) {
            logger.warn("[parse][wrong address]" + address);
        }
    }
    return result;
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort) LinkedList(java.util.LinkedList) SocketException(java.net.SocketException)

Example 60 with HostPort

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

the class IpUtils method parse.

public static List<InetSocketAddress> parse(String addressDesc) {
    List<HostPort> hostPorts = parseAsHostPorts(addressDesc);
    List<InetSocketAddress> result = new LinkedList<>();
    hostPorts.forEach((hostPort) -> {
        result.add(new InetSocketAddress(hostPort.getHost(), hostPort.getPort()));
    });
    return result;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) HostPort(com.ctrip.xpipe.endpoint.HostPort) LinkedList(java.util.LinkedList)

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