use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class DefaultXpipeMetaManagerTest method findShard.
@Test
public void findShard() {
XpipeMetaManager.MetaDesc metaDesc = metaManager.findMetaDesc(new HostPort("127.0.0.1", 8000));
Assert.assertEquals("jq", metaDesc.getDcId());
Assert.assertEquals("cluster1", metaDesc.getClusterId());
Assert.assertEquals("shard1", metaDesc.getShardId());
metaDesc = metaManager.findMetaDesc(new HostPort("127.0.0.1", 6000));
Assert.assertEquals("jq", metaDesc.getDcId());
Assert.assertEquals("cluster1", metaDesc.getClusterId());
Assert.assertEquals("shard1", metaDesc.getShardId());
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class HickwallMetric method metricName.
private String metricName(MetricData md) {
HostPort hostPort = md.getHostPort();
String metricNamePrefix = toMetricNamePrefix(md);
String metricName = metricNamePrefix;
if (hostPort != null) {
metricName += "." + hostPort.getHost() + "." + hostPort.getPort() + "." + getLocalIP();
}
return metricName;
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class HickwallMetricTest method testGetFormattedRedisAddr.
@Test
public void testGetFormattedRedisAddr() {
HostPort hostPort = new HostPort("10.2.2.2", 6379);
String result = hickwallMetricProxy.getFormattedRedisAddr(hostPort);
Assert.assertEquals("10_2_2_2_6379", result);
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class HickwallMetricTest method testHickWall.
@Test
public void testHickWall() throws MetricProxyException, IOException {
int port = 11111;
logger.info("[testHickWall]{}", port);
scheduled.scheduleAtFixedRate(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
List<MetricData> data = new LinkedList<>();
HostPort hostPort = new HostPort("127.0.0.1", port);
MetricData metricData = new MetricData("delay", "cluster", "shard");
metricData.setValue(1000);
metricData.setHostPort(hostPort);
metricData.setTimestampMilli(System.currentTimeMillis());
data.add(metricData);
hickwallMetricProxy.writeBinMultiDataPoint(data);
}
}, 0, 2, TimeUnit.SECONDS);
waitForAnyKeyToExit();
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class DefaultSentinelCollector method checkAndDelete.
protected Set<SentinelHello> checkAndDelete(String sentinelMonitorName, Set<HostPort> masterDcSentinels, Set<SentinelHello> hellos, QuorumConfig quorumConfig) {
Set<SentinelHello> toDelete = new HashSet<>();
hellos.forEach((hello) -> {
if (!hello.getMonitorName().equals(sentinelMonitorName)) {
toDelete.add(hello);
}
});
hellos.forEach((hello) -> {
HostPort sentinel = hello.getSentinelAddr();
if (!masterDcSentinels.contains(sentinel)) {
toDelete.add(hello);
}
});
toDelete.forEach((delete) -> {
hellos.remove(delete);
});
int toRemove = hellos.size() - quorumConfig.getTotal();
if (toRemove > 0) {
int i = 0;
for (SentinelHello hello : hellos) {
i++;
toDelete.add(hello);
if (i >= toRemove) {
break;
}
}
}
toDelete.forEach((delete) -> {
hellos.remove(delete);
});
return toDelete;
}
Aggregations