Search in sources :

Example 1 with Pair

use of com.ctrip.xpipe.tuple.Pair in project x-pipe by ctripcorp.

the class DecoratorManager method generateTitleAndContent.

public Pair<String, String> generateTitleAndContent(Map<ALERT_TYPE, Set<AlertEntity>> alerts) {
    Decorator decorator = decorators.get(ScheduledAlertMessageDecorator.ID);
    ScheduledAlertMessageDecorator scheduledDecorator = (ScheduledAlertMessageDecorator) decorator;
    String content = scheduledDecorator.generateBody(alerts);
    String title = scheduledDecorator.generateTitle();
    return new Pair<>(title, content);
}
Also used : Decorator(com.ctrip.xpipe.redis.console.alert.decorator.Decorator) RecoverMessageDecorator(com.ctrip.xpipe.redis.console.alert.decorator.RecoverMessageDecorator) ScheduledAlertMessageDecorator(com.ctrip.xpipe.redis.console.alert.decorator.ScheduledAlertMessageDecorator) AlertMessageDecorator(com.ctrip.xpipe.redis.console.alert.decorator.AlertMessageDecorator) ScheduledAlertMessageDecorator(com.ctrip.xpipe.redis.console.alert.decorator.ScheduledAlertMessageDecorator) Pair(com.ctrip.xpipe.tuple.Pair)

Example 2 with Pair

use of com.ctrip.xpipe.tuple.Pair in project x-pipe by ctripcorp.

the class AbstractKeeperIntegratedMultiDc method makeKeeperRight.

private void makeKeeperRight() throws Exception {
    logger.info(remarkableMessage("makeKeeperRight"));
    DcMeta dcMeta = activeDc();
    List<KeeperMeta> keepers = getDcKeepers(dcMeta.getId(), getClusterId(), getShardId());
    RedisMeta redisMaster = getRedisMaster();
    KeeperStateChangeJob job = new KeeperStateChangeJob(keepers, new Pair<String, Integer>(redisMaster.getIp(), redisMaster.getPort()), getXpipeNettyClientKeyedObjectPool(), scheduled, executors);
    job.execute().sync();
    for (DcMeta backupDc : backupDcs()) {
        List<KeeperMeta> backupKeepers = getDcKeepers(backupDc.getId(), getClusterId(), getShardId());
        job = new KeeperStateChangeJob(backupKeepers, new Pair<String, Integer>(activeDcKeeperActive.getIp(), activeDcKeeperActive.getPort()), getXpipeNettyClientKeyedObjectPool(), scheduled, executors);
        job.execute().sync();
    }
}
Also used : KeeperStateChangeJob(com.ctrip.xpipe.redis.meta.server.job.KeeperStateChangeJob) Pair(com.ctrip.xpipe.tuple.Pair)

Example 3 with Pair

use of com.ctrip.xpipe.tuple.Pair in project x-pipe by ctripcorp.

the class BaseSampleMonitor method generatePlan.

@Override
public Collection<BaseSamplePlan<T>> generatePlan(List<DcMeta> dcMetas) {
    Map<Pair<String, String>, BaseSamplePlan<T>> plans = new HashMap<>();
    for (DcMeta dcMeta : dcMetas) {
        for (ClusterMeta clusterMeta : dcMeta.getClusters().values()) {
            if (!addCluster(dcMeta.getId(), clusterMeta)) {
                continue;
            }
            for (ShardMeta shardMeta : clusterMeta.getShards().values()) {
                Pair<String, String> cs = new Pair<>(clusterMeta.getId(), shardMeta.getId());
                BaseSamplePlan<T> plan = plans.get(cs);
                if (plan == null) {
                    plan = createPlan(dcMeta.getId(), clusterMeta.getId(), shardMeta.getId());
                    plans.put(cs, plan);
                }
                for (RedisMeta redisMeta : shardMeta.getRedises()) {
                    log.debug("[generatePlan]{}", redisMeta.desc());
                    addRedis(plan, dcMeta.getId(), redisMeta);
                }
                if (plan.isEmpty()) {
                    plans.remove(cs);
                }
            }
        }
    }
    return plans.values();
}
Also used : ClusterMeta(com.ctrip.xpipe.redis.core.entity.ClusterMeta) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) DcMeta(com.ctrip.xpipe.redis.core.entity.DcMeta) ShardMeta(com.ctrip.xpipe.redis.core.entity.ShardMeta) RedisMeta(com.ctrip.xpipe.redis.core.entity.RedisMeta) Pair(com.ctrip.xpipe.tuple.Pair)

Example 4 with Pair

use of com.ctrip.xpipe.tuple.Pair in project x-pipe by ctripcorp.

the class RedisServiceImplTest method testSub.

@Test
public void testSub() {
    List<Pair<String, Integer>> first = Lists.newArrayList(Pair.from("127.0.0.1", 1111), Pair.from("127.0.0.1", 1112), Pair.from("127.0.0.1", 1113));
    List<RedisTbl> second = Lists.newArrayList(new RedisTbl().setRedisIp("127.0.0.1").setRedisPort(1111), new RedisTbl().setRedisIp("127.0.0.1").setRedisPort(1112), new RedisTbl().setRedisIp("127.0.0.1").setRedisPort(9999));
    List<Pair<String, Integer>> sub = redisService.sub(first, second);
    Assert.assertEquals(1, sub.size());
}
Also used : RedisTbl(com.ctrip.xpipe.redis.console.model.RedisTbl) Pair(com.ctrip.xpipe.tuple.Pair) Test(org.junit.Test)

Example 5 with Pair

use of com.ctrip.xpipe.tuple.Pair in project x-pipe by ctripcorp.

the class BecomePrimaryAction method chooseNewMaster.

@Override
protected Pair<String, Integer> chooseNewMaster(String clusterId, String shardId) {
    List<RedisMeta> redises = dcMetaCache.getShardRedises(clusterId, shardId);
    String desc = MetaUtils.toString(redises);
    executionLog.info("[chooseNewMaster][from]" + desc);
    RedisMeta newMaster = newMasterChooser.choose(redises);
    if (newMaster == null) {
        throw ChooseNewMasterFailException.chooseNull(redises);
    }
    return new Pair<>(newMaster.getIp(), newMaster.getPort());
}
Also used : RedisMeta(com.ctrip.xpipe.redis.core.entity.RedisMeta) Pair(com.ctrip.xpipe.tuple.Pair)

Aggregations

Pair (com.ctrip.xpipe.tuple.Pair)13 RedisMeta (com.ctrip.xpipe.redis.core.entity.RedisMeta)4 Test (org.junit.Test)4 AlertMessageDecorator (com.ctrip.xpipe.redis.console.alert.decorator.AlertMessageDecorator)2 Decorator (com.ctrip.xpipe.redis.console.alert.decorator.Decorator)2 RecoverMessageDecorator (com.ctrip.xpipe.redis.console.alert.decorator.RecoverMessageDecorator)2 ScheduledAlertMessageDecorator (com.ctrip.xpipe.redis.console.alert.decorator.ScheduledAlertMessageDecorator)2 RedisTbl (com.ctrip.xpipe.redis.console.model.RedisTbl)2 KeeperMeta (com.ctrip.xpipe.redis.core.entity.KeeperMeta)2 LinkedList (java.util.LinkedList)2 SERVER_ROLE (com.ctrip.xpipe.api.server.Server.SERVER_ROLE)1 AbstractExceptionLogTask (com.ctrip.xpipe.concurrent.AbstractExceptionLogTask)1 ClusterMeta (com.ctrip.xpipe.redis.core.entity.ClusterMeta)1 DcMeta (com.ctrip.xpipe.redis.core.entity.DcMeta)1 Redis (com.ctrip.xpipe.redis.core.entity.Redis)1 ShardMeta (com.ctrip.xpipe.redis.core.entity.ShardMeta)1 XpipeMetaManager (com.ctrip.xpipe.redis.core.meta.XpipeMetaManager)1 DefaultXpipeMetaManager (com.ctrip.xpipe.redis.core.meta.impl.DefaultXpipeMetaManager)1 SlaveRole (com.ctrip.xpipe.redis.core.protocal.pojo.SlaveRole)1 AbstractMetaServerTest (com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)1