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);
}
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();
}
}
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();
}
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());
}
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());
}
Aggregations