Search in sources :

Example 26 with HostPort

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());
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort) XpipeMetaManager(com.ctrip.xpipe.redis.core.meta.XpipeMetaManager) Test(org.junit.Test) AbstractRedisTest(com.ctrip.xpipe.redis.core.AbstractRedisTest)

Example 27 with HostPort

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;
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort)

Example 28 with HostPort

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);
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort) Test(org.junit.Test) AbstractServiceTest(com.ctrip.xpipe.AbstractServiceTest)

Example 29 with HostPort

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();
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort) AbstractExceptionLogTask(com.ctrip.xpipe.concurrent.AbstractExceptionLogTask) List(java.util.List) LinkedList(java.util.LinkedList) IOException(java.io.IOException) MetricProxyException(com.ctrip.xpipe.metric.MetricProxyException) MetricData(com.ctrip.xpipe.metric.MetricData) Test(org.junit.Test) AbstractServiceTest(com.ctrip.xpipe.AbstractServiceTest)

Example 30 with HostPort

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;
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort) HashSet(java.util.HashSet)

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