use of com.ctrip.xpipe.redis.core.entity.XpipeMeta in project x-pipe by ctripcorp.
the class RemoveUnusedRedisTest method beforeRemoveUnusedRedisTest.
@Before
public void beforeRemoveUnusedRedisTest() throws Exception {
MockitoAnnotations.initMocks(this);
// mock datas
XpipeMeta xpipeMeta = new XpipeMeta().addDc(new DcMeta());
when(metaCache.getXpipeMeta()).thenReturn(xpipeMeta);
manager.executors = Executors.newFixedThreadPool(OsUtils.getCpuCount());
manager.pingAndDelayExecutor = Executors.newFixedThreadPool(OsUtils.getCpuCount());
// random port to avoid port conflict
port = randomPort();
server = startServer(port, new Callable<String>() {
@Override
public String call() throws Exception {
return "+OK\r\n";
}
});
}
use of com.ctrip.xpipe.redis.core.entity.XpipeMeta in project x-pipe by ctripcorp.
the class MetaUpdate method getStats.
@RequestMapping(value = "/stats", method = RequestMethod.GET)
public Map<String, Integer> getStats() {
XpipeMeta xpipeMeta = metaCache.getXpipeMeta();
ClusterShardCounter counter = new ClusterShardCounter();
xpipeMeta.accept(counter);
HashMap<String, Integer> counts = new HashMap<>();
counts.put("clusterCount", counter.getClusterCount());
counts.put("shardCount", counter.getShardCount());
return counts;
}
use of com.ctrip.xpipe.redis.core.entity.XpipeMeta in project x-pipe by ctripcorp.
the class MetaCloneTest method testClone.
@Test
public void testClone() {
XpipeMeta xpipeMeta = getXpipeMeta();
DcMeta dcMeta = xpipeMeta.getDcs().values().iterator().next();
DcMeta clone = MetaClone.clone(dcMeta);
Assert.assertEquals(dcMeta, clone);
clone.setId(randomString());
Assert.assertNotEquals(dcMeta, clone);
}
use of com.ctrip.xpipe.redis.core.entity.XpipeMeta in project x-pipe by ctripcorp.
the class MetaJacksonTest method testJackson.
@Test
public void testJackson() throws IOException {
// for get config from console, use raw ObjectMapper
ObjectMapper objectMapper = new ObjectMapper();
XpipeMeta rawMeta = getXpipeMeta();
String metaString = objectMapper.writeValueAsString(rawMeta);
XpipeMeta metaBack = objectMapper.readValue(metaString, XpipeMeta.class);
Assert.assertEquals(metaBack, rawMeta);
}
use of com.ctrip.xpipe.redis.core.entity.XpipeMeta in project x-pipe by ctripcorp.
the class DefaultDcMetaCacheTest method testChangeDcMetaLog.
@Test
public void testChangeDcMetaLog() {
// just check exception
EventMonitor.DEFAULT.logEvent("type", getTestName());
XpipeMeta xpipeMeta = getXpipeMeta();
DcMeta dcMeta = (DcMeta) xpipeMeta.getDcs().values().toArray()[0];
DcMeta future = MetaClone.clone(dcMeta);
ClusterMeta futureCluster = (ClusterMeta) future.getClusters().values().toArray()[0];
futureCluster.addShard(new ShardMeta().setId(randomString(5)));
future.addCluster(new ClusterMeta().setId(randomString(10)));
dcMetaCache.changeDcMeta(dcMeta, future);
dcMetaCache.clusterAdded(new ClusterMeta().setId("add_" + randomString(5)));
dcMetaCache.clusterDeleted("del_" + randomString(5));
}
Aggregations