本文整理了Java中com.liveramp.hank.coordinator.zk.ZkRingGroup
类的一些代码示例,展示了ZkRingGroup
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkRingGroup
类的具体详情如下:
包路径:com.liveramp.hank.coordinator.zk.ZkRingGroup
类名称:ZkRingGroup
暂无
代码示例来源:origin: LiveRamp/hank
@Override
public RingGroup addRingGroup(String ringGroupName, String domainGroupName) throws IOException {
try {
RingGroup rg = ZkRingGroup.create(zk, ZkPath.append(ringGroupsRoot, ringGroupName),
(ZkDomainGroup)getDomainGroup(domainGroupName), this);
ringGroups.put(ringGroupName, (ZkRingGroup)rg);
return rg;
} catch (Exception e) {
throw new IOException(e);
}
}
代码示例来源:origin: LiveRamp/hank
@Override
public boolean deleteRingGroup(String ringGroupName) throws IOException {
ZkRingGroup ringGroup = ringGroups.remove(ringGroupName);
if (ringGroup == null) {
return false;
}
return ringGroup.delete();
}
}
代码示例来源:origin: LiveRamp/hank
@Override
public boolean removeRing(int ringNum) throws IOException {
ZkRing ring = rings.remove("ring-" + Integer.toString(ringNum));
if (ring == null) {
return false;
} else {
ring.delete();
fireDataLocationChangeListeners();
return true;
}
}
代码示例来源:origin: LiveRamp/hank
@Test
public void testLoad() throws Exception {
create(ring_group, ZkPath.append(dg_root, "myDomainGroup"));
createRing(1);
createRing(2);
createRing(3);
MockDomainGroup dg = new MockDomainGroup("myDomainGroup");
ZkRingGroup rg = new ZkRingGroup(getZk(), ring_group, dg, coordinator);
assertEquals("ring group name", "myRingGroup", rg.getName());
assertEquals("num rings", 3, rg.getRings().size());
assertEquals("domain group config", dg, rg.getDomainGroup());
assertEquals("ring group for localhost:2", 2, rg.getRingForHost(new PartitionServerAddress("localhost", 2)).getRingNumber());
assertEquals("ring group by number", 3, rg.getRing(3).getRingNumber());
}
代码示例来源:origin: LiveRamp/hank
ZkRingGroup rg = new ZkRingGroup(getZk(), ring_group, dg, coordinator);
rg.addDataLocationChangeListener(dataLocationChangeListener);
Host host = rg.getRing(1).addHost(address, Collections.emptyList());
WaitUntil.orDie(() -> dataLocationChangeListener.isCalled);
assertTrue(dataLocationChangeListener.isCalled());
dataLocationChangeListener.clear();
rg.getRing(1).getHostByAddress(address).setState(HostState.SERVING);
WaitUntil.orDie(() -> dataLocationChangeListener.isCalled);
assertTrue(dataLocationChangeListener.isCalled());
代码示例来源:origin: LiveRamp/hank
@Before
public void setUp() throws Exception {
create(domains_root);
create(domain_groups_root);
create(ring_groups_root);
ZkDomain.create(getZk(), domains_root, "domain0", 1, ConstantStorageEngine.Factory.class.getName(), "---", ConstantPartitioner.class.getName(), 0, Collections.emptyList());
ZkDomainGroup domainGroup = ZkDomainGroup.create(getZk(), null, domain_groups_root, "myDomainGroup");
Map<Domain, Integer> domainIdToVersion = new HashMap<>();
domainGroup.setDomainVersions(domainIdToVersion);
ZkRingGroup rg = ZkRingGroup.create(getZk(), ring_groups_root + "/myRingGroup", domainGroup, new MockCoordinator());
Ring rc = rg.addRing(1);
rc.addHost(new PartitionServerAddress("localhost", 1), Collections.emptyList());
coord = getCoord();
}
代码示例来源:origin: LiveRamp/hank
public static ZkRingGroup create(ZooKeeperPlus zk, String path, ZkDomainGroup domainGroup, Coordinator coordinator) throws KeeperException, InterruptedException, IOException {
zk.create(path, domainGroup.getName().getBytes());
zk.create(ZkPath.append(path, CLIENTS_PATH), null);
zk.create(ZkPath.append(path, SERVERS_PATH), null);
zk.create(ZkPath.append(path, DotComplete.NODE_NAME), null);
return new ZkRingGroup(zk, path, domainGroup, coordinator);
}
代码示例来源:origin: LiveRamp/hank
@Test
public void testClaimRingGroupConductor() throws Exception {
ZkDomainGroup dg = ZkDomainGroup.create(getZk(), null, dg_root, "blah");
dg.setDomainVersions(Collections.emptyMap());
final RingGroup rg = ZkRingGroup.create(getZk(), ring_group, dg, coordinator);
create(ZkPath.append(ring_group, ZkRingGroup.RING_GROUP_CONDUCTOR_ONLINE_PATH));
assertFalse(rg.claimRingGroupConductor(RingGroupConductorMode.ACTIVE));
getZk().delete(ZkPath.append(ring_group, ZkRingGroup.RING_GROUP_CONDUCTOR_ONLINE_PATH), -1);
assertTrue(rg.claimRingGroupConductor(RingGroupConductorMode.ACTIVE));
assertFalse(rg.claimRingGroupConductor(RingGroupConductorMode.ACTIVE));
rg.releaseRingGroupConductor();
assertTrue(rg.claimRingGroupConductor(RingGroupConductorMode.ACTIVE));
WaitUntil.orDie(() -> {
try {
return RingGroupConductorMode.ACTIVE.equals(rg.getRingGroupConductorMode());
} catch (IOException e) {
throw new RuntimeException(e);
}
});
assertEquals(RingGroupConductorMode.ACTIVE, rg.getRingGroupConductorMode());
}
代码示例来源:origin: LiveRamp/hank
@Override
public Ring addRing(int ringNum) throws IOException {
try {
ZkRing ring = ZkRing.create(zk, coordinator, ringGroupPath, ringNum, this, dataLocationChangeListener);
rings.put("ring-" + Integer.toString(ring.getRingNumber()), ring);
fireDataLocationChangeListeners();
return ring;
} catch (Exception e) {
throw new IOException(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!