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;
}
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;
}
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);
}
}
}
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;
}
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;
}
Aggregations