Search in sources :

Example 46 with HostPort

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

the class ClientConfigMonitor method checkClusterInfo.

private void checkClusterInfo(OuterClientService.ClusterInfo clusterInfo) {
    if (clusterInfo.getGroups() == null || clusterInfo.getGroups().isEmpty())
        return;
    String clusterName = clusterInfo.getName(), shardName;
    for (OuterClientService.GroupInfo group : clusterInfo.getGroups()) {
        List<OuterClientService.InstanceInfo> instances = group.getInstances();
        if (instances == null || instances.isEmpty())
            continue;
        shardName = group.getName();
        for (OuterClientService.InstanceInfo instance : instances) {
            if (!instance.isCanRead()) {
                alertManager.alert(clusterName, shardName, new HostPort(instance.getIPAddress(), instance.getPort()), ALERT_TYPE.CLIENT_INSTANCE_NOT_OK, "instance cannot read");
            }
            if (!instance.isStatus()) {
                alertManager.alert(clusterName, shardName, new HostPort(instance.getIPAddress(), instance.getPort()), ALERT_TYPE.CLIENT_INSTANCE_NOT_OK, "instance is not valid");
            }
        }
    }
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort) OuterClientService(com.ctrip.xpipe.api.migration.OuterClientService)

Example 47 with HostPort

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

the class BacklogActiveMonitor method sampleInfoReplication.

public void sampleInfoReplication(long recordTime, BaseSamplePlan<InstanceInfoReplicationResult> plan) {
    for (HostPort hostPort : plan.getHostPort2SampleResult().keySet()) {
        RedisSession session = sessionManager.findOrCreateSession(hostPort.getHost(), hostPort.getPort());
        session.infoReplication(new Callbackable<String>() {

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

            @Override
            public void fail(Throwable throwable) {
                addInstanceFail(recordTime, hostPort.getHost(), hostPort.getPort(), throwable);
            }
        });
    }
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort)

Example 48 with HostPort

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

the class BecomePrimaryAction method doChangePrimaryDc.

protected PrimaryDcChangeMessage doChangePrimaryDc(String clusterId, String shardId, String newPrimaryDc, MasterInfo masterInfo) {
    doChangeMetaCache(clusterId, shardId, newPrimaryDc);
    executionLog.info(String.format("[chooseNewMaster][begin]"));
    Pair<String, Integer> newMaster = chooseNewMaster(clusterId, shardId);
    executionLog.info(String.format("[chooseNewMaster]%s:%d", newMaster.getKey(), newMaster.getValue()));
    // wait for slave to achieve master offset
    offsetWaiter.tryWaitfor(new HostPort(newMaster.getKey(), newMaster.getValue()), masterInfo, executionLog);
    List<RedisMeta> slaves = getAllSlaves(newMaster, dcMetaCache.getShardRedises(clusterId, shardId));
    makeRedisesOk(newMaster, slaves);
    makeKeepersOk(clusterId, shardId, newMaster);
    changeSentinel(clusterId, shardId, newMaster);
    return new PrimaryDcChangeMessage(executionLog.getLog(), newMaster.getKey(), newMaster.getValue());
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort) RedisMeta(com.ctrip.xpipe.redis.core.entity.RedisMeta) PrimaryDcChangeMessage(com.ctrip.xpipe.redis.core.metaserver.MetaServerConsoleService.PrimaryDcChangeMessage)

Example 49 with HostPort

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

the class DefaultPrimaryDcPrepareToChange method prepare.

@Override
public MetaServerConsoleService.PreviousPrimaryDcMessage prepare(String clusterId, String shardId) {
    logger.info("[prepare]{}, {}", clusterId, shardId);
    MetaServerConsoleService.PreviousPrimaryDcMessage message = new MetaServerConsoleService.PreviousPrimaryDcMessage();
    ExecutionLog executionLog = new ExecutionLog(String.format("meta server:%s", currentClusterServer.getClusterInfo()));
    Pair<String, Integer> keeperMaster = currentMetaManager.getKeeperMaster(clusterId, shardId);
    message.setMasterAddr(new HostPort(keeperMaster.getKey(), keeperMaster.getValue()));
    executionLog.info("[prepare]" + keeperMaster);
    RedisInfo redisInfo = getInfoReplication(keeperMaster, executionLog);
    MasterInfo masterInfo = convert(redisInfo, executionLog);
    message.setMasterInfo(masterInfo);
    logger.info("[prepare]{}, {}, {}", keeperMaster, redisInfo, masterInfo);
    makeMasterReadOnly(clusterId, shardId, keeperMaster, true, executionLog);
    removeSentinel(clusterId, shardId, executionLog);
    message.setMessage(executionLog.getLog());
    return message;
}
Also used : MasterInfo(com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo) ExecutionLog(com.ctrip.xpipe.redis.meta.server.dcchange.ExecutionLog) MetaServerConsoleService(com.ctrip.xpipe.redis.core.metaserver.MetaServerConsoleService) HostPort(com.ctrip.xpipe.endpoint.HostPort) RedisInfo(com.ctrip.xpipe.redis.core.protocal.pojo.RedisInfo)

Example 50 with HostPort

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

the class DefaultPrimaryDcPrepareToChange method addSentinel.

private void addSentinel(String clusterId, String shardId, ExecutionLog executionLog) {
    logger.info("[addSentinel]{},{}", clusterId, shardId);
    Pair<String, Integer> keeperMaster = currentMetaManager.getKeeperMaster(clusterId, shardId);
    sentinelManager.addSentinel(clusterId, shardId, new HostPort(keeperMaster.getKey(), keeperMaster.getValue()), executionLog);
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort)

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