CurrentMeta implements Releasable { public RedisMeta getCurrentMaster(String clusterId, String shardId) { CurrentShardMeta currentShardMeta = getCurrentShardMetaOrThrowException(clusterId, shardId); if (currentShardMeta instanceof CurrentCRDTShardMeta) { return ((CurrentCRDTShardMeta) currentShardMeta).getCurrentMaster(); } else if (currentShardMeta instanceof CurrentKeeperShardMeta) { Pair<String, Integer> master = ((CurrentKeeperShardMeta) currentShardMeta).getKeeperMaster(); if (null == master) return null; return new RedisMeta().setIp(master.getKey()).setPort(master.getValue()); } return null; }  Set<String> allClusters(); boolean hasCluster(String clusterId); boolean hasShard(String clusterId, String shardId); boolean watchIfNotWatched(String clusterId, String shardId); void setSurviveKeepers(String clusterId, String shardId, List<KeeperMeta> surviveKeepers,
			KeeperMeta activeKeeper); void addResource(String clusterId, String shardId, Releasable releasable); List<KeeperMeta> getSurviveKeepers(String clusterId, String shardId); boolean setKeeperActive(String clusterId, String shardId, KeeperMeta keeperMeta); KeeperMeta getKeeperActive(String clusterId, String shardId); boolean setKeeperMaster(String clusterId, String shardId, Pair<String, Integer> keeperMaster); Pair<String, Integer> getKeeperMaster(String clusterId, String shardId); void setCurrentCRDTMaster(String clusterId, String shardId,  RedisMeta peerMaster); RedisMeta getCurrentCRDTMaster(String clusterId, String shardId); RedisMeta getCurrentMaster(String clusterId, String shardId); void setPeerMaster(String dcId, String clusterId, String shardId, RedisMeta peerMaster); RedisMeta getPeerMaster(String dcId, String clusterId, String shardId); void removePeerMaster(String dcId, String clusterId, String shardId); Set<String> getUpstreamPeerDcs(String clusterId, String shardId); List<RedisMeta> getAllPeerMasters(String clusterId, String shardId); @Override void release(); void addCluster(final ClusterMeta clusterMeta); CurrentClusterMeta removeCluster(String clusterId); void changeCluster(ClusterMetaComparator comparator); @Override String toString(); static CurrentMeta fromJson(String json);  }
@Test public void testGetCurrentMaster() { Assert.assertEquals(new RedisMeta().setIp("127.0.0.1").setPort(6379), currentMeta.getCurrentMaster(clusterId, shardId)); Assert.assertNull(currentMeta.getCurrentMaster(biClusterId, biShardId)); currentMeta.setCurrentCRDTMaster(biClusterId, biShardId, new RedisMeta().setIp("10.0.0.1").setPort(6379).setGid(1L)); Assert.assertEquals(new RedisMeta().setIp("10.0.0.1").setPort(6379).setGid(1L), currentMeta.getCurrentMaster(biClusterId, biShardId)); }