Search in sources :

Example 41 with HostPort

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

the class ScheduledAlertMessageDecoratorTest method generateBody.

@Test
public void generateBody() throws Exception {
    HostPort hostPort = new HostPort("192.168.1.10", 6379);
    Map<ALERT_TYPE, Set<AlertEntity>> alerts = new HashMap<>();
    alerts.put(ALERT_TYPE.CLIENT_INCONSIS, Collections.singleton(new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.CLIENT_INCONSIS)));
    alerts.put(ALERT_TYPE.XREDIS_VERSION_NOT_VALID, Collections.singleton(new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.XREDIS_VERSION_NOT_VALID)));
    String body = decorator.generateBody(alerts);
    logger.info("{}", body);
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) HostPort(com.ctrip.xpipe.endpoint.HostPort) AlertEntity(com.ctrip.xpipe.redis.console.alert.AlertEntity) ALERT_TYPE(com.ctrip.xpipe.redis.console.alert.ALERT_TYPE) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 42 with HostPort

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

the class DefaultRedisSessionManager method findOrCreateSession.

@Override
public RedisSession findOrCreateSession(String host, int port) {
    if (StringUtil.isEmpty(host) || port == 0) {
        throw new IllegalArgumentException("Redis Host/Port can not be empty: " + host + ":" + port);
    }
    HostPort hostPort = new HostPort(host, port);
    RedisSession session = sessions.get(hostPort);
    if (session == null) {
        synchronized (this) {
            session = sessions.get(hostPort);
            if (session == null) {
                session = new RedisSession(findRedisConnection(host, port), hostPort, executors, pingAndDelayExecutor);
                sessions.put(hostPort, session);
            }
        }
    }
    return session;
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort)

Example 43 with HostPort

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

the class VersionMonitor method sampleVersionCheck.

private void sampleVersionCheck(long startNanoTime, BaseSamplePlan<VersionInstanceResult> plan) {
    for (Map.Entry<HostPort, VersionInstanceResult> entry : plan.getHostPort2SampleResult().entrySet()) {
        HostPort hostPort = entry.getKey();
        try {
            RedisSession redisSession = findRedisSession(hostPort);
            redisSession.infoServer(new Callbackable<String>() {

                @Override
                public void success(String message) {
                    addInstanceSuccess(startNanoTime, hostPort.getHost(), hostPort.getPort(), message);
                }

                @Override
                public void fail(Throwable throwable) {
                    addInstanceFail(startNanoTime, hostPort.getHost(), hostPort.getPort(), throwable);
                }
            });
        } catch (Exception e) {
            addInstanceFail(startNanoTime, hostPort.getHost(), hostPort.getPort(), e);
        }
    }
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort) Map(java.util.Map)

Example 44 with HostPort

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

the class SentinelCollector4Keeper method doCollect.

private void doCollect(ClusterShardHostPort entry, InstanceSentinelResult result) {
    Set<SentinelHello> hellos = result.getHellos();
    for (SentinelHello hello : hellos) {
        HostPort masterAddr = hello.getMasterAddr();
        String monitorName = hello.getMonitorName();
        boolean masterGood = ObjectUtils.equals(masterAddr, metaCache.findMasterInSameShard(entry.getHostPort()));
        boolean monitorGood = StringUtil.trimEquals(monitorName, metaCache.getSentinelMonitorName(entry.getClusterName(), entry.getShardName()));
        SentinelCollectorAction.getAction(masterGood, monitorGood).doAction(this, hello, entry);
    }
}
Also used : ClusterShardHostPort(com.ctrip.xpipe.endpoint.ClusterShardHostPort) HostPort(com.ctrip.xpipe.endpoint.HostPort)

Example 45 with HostPort

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

the class OuterClientServiceProcessor method onEvent.

@Override
public void onEvent(AbstractInstanceEvent instanceEvent) throws HealthEventProcessorException {
    HostPort hostPort = instanceEvent.getHostPort();
    Pair<String, String> clusterShard = metaCache.findClusterShard(hostPort);
    if (!instanceInBackupDc(hostPort)) {
        logger.info("[onEvent][instance not in backupDc]{}, {}", clusterShard, hostPort);
        return;
    }
    ClusterShardHostPort clusterShardHostPort = new ClusterShardHostPort(hostPort);
    if (clusterShard != null) {
        clusterShardHostPort.setClusterName(clusterShard.getKey());
        clusterShardHostPort.setShardName(clusterShard.getValue());
    }
    if (instanceEvent instanceof InstanceUp) {
        finalStateSetterManager.set(clusterShardHostPort, true);
    } else if (instanceEvent instanceof InstanceDown) {
        if (masterUp(clusterShardHostPort)) {
            quorumMarkInstanceDown(clusterShardHostPort);
        } else {
            logger.info("[onEvent][master down, do not call client service]{}", instanceEvent);
        }
    } else {
        throw new IllegalStateException("unknown event:" + instanceEvent);
    }
}
Also used : ClusterShardHostPort(com.ctrip.xpipe.endpoint.ClusterShardHostPort) HostPort(com.ctrip.xpipe.endpoint.HostPort) ClusterShardHostPort(com.ctrip.xpipe.endpoint.ClusterShardHostPort)

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