本文整理了Java中com.alibaba.wasp.zookeeper.ZKAssign.getData()
方法的一些代码示例,展示了ZKAssign.getData()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKAssign.getData()
方法的具体详情如下:
包路径:com.alibaba.wasp.zookeeper.ZKAssign
类名称:ZKAssign
方法名:getData
[英]Gets the current data in the unassigned node for the specified entityGroup name or fully-qualified path.
Returns null if the entityGroup does not currently have a node.
Sets a watch on the node if the node exists.
[中]获取指定entityGroup名称或完全限定路径的未分配节点中的当前数据。
如果entityGroup当前没有节点,则返回null。
如果节点存在,则在节点上设置监视。
代码示例来源:origin: alibaba/wasp
/**
* @param path
* @return True if znode is in SPLIT or SPLITTING state.
* @throws org.apache.zookeeper.KeeperException
* Can happen if the znode went away in meantime.
* @throws com.alibaba.wasp.DeserializationException
*/
private boolean isSplitOrSplitting(final String path) throws KeeperException,
DeserializationException {
boolean result = false;
// This may fail if the SPLIT or SPLITTING znode gets cleaned up before we
// can get data from it.
byte[] data = ZKAssign.getData(watcher, path);
if (data == null)
return false;
EntityGroupTransaction rt = EntityGroupTransaction.parseFrom(data);
switch (rt.getEventType()) {
case FSERVER_ZK_ENTITYGROUP_SPLIT:
case FSERVER_ZK_ENTITYGROUP_SPLITTING:
result = true;
break;
default:
break;
}
return result;
}
代码示例来源:origin: alibaba/wasp
EntityGroupTransaction rt = null;
try {
byte[] data = ZKAssign.getData(watcher, egInfo.getEncodedName());
代码示例来源:origin: alibaba/wasp
byte[] bytes = ZKAssign.getData(zkw, entityGroup.getEncodedName());
rt = getEntityGroupTransition(bytes);
if (rt.getEventType() != EventType.M_ZK_ENTITYGROUP_OFFLINE) {
代码示例来源:origin: alibaba/wasp
private void openEntityGroup(Server server, FServerServices rss, FTable ftd,
EntityGroupInfo egi) throws IOException, NodeExistsException,
KeeperException, DeserializationException {
// Create it OFFLINE node, which is what Master set before sending OPEN RPC
ZKAssign.createNodeOffline(server.getZooKeeper(), egi,
server.getServerName());
OpenEntityGroupHandler openHandler = new OpenEntityGroupHandler(server,
rss, egi, ftd);
openHandler.process();
// This parse is not used?
EntityGroupTransaction.parseFrom(ZKAssign.getData(server.getZooKeeper(),
egi.getEncodedName()));
// delete the node, which is what Master do after the entityGroup is opened
ZKAssign.deleteNode(server.getZooKeeper(), egi.getEncodedName(),
EventType.FSERVER_ZK_ENTITYGROUP_OPENED);
}
}
代码示例来源:origin: alibaba/wasp
+ stats);
EntityGroupTransaction rtd = EntityGroupTransaction.parseFrom(ZKAssign
.getData(zkw, egi.getEncodedName()));
代码示例来源:origin: alibaba/wasp
@Test
public void testFailedOpenEntityGroup() throws Exception {
Server server = new MockServer(WTU);
FServerServices rsServices = new MockFServerServices();
// Create it OFFLINE, which is what it expects
ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_EGI,
server.getServerName());
// Create the handler
OpenEntityGroupHandler handler = new OpenEntityGroupHandler(server,
rsServices, TEST_EGI, TEST_FTD) {
@Override
EntityGroup openEntityGroup() {
// Fake failure of opening a entityGroup due to an IOE, which is caught
return null;
}
};
handler.process();
// Handler should have transitioned it to FAILED_OPEN
EntityGroupTransaction rt = EntityGroupTransaction.parseFrom(ZKAssign
.getData(server.getZooKeeper(), TEST_EGI.getEncodedName()));
assertEquals(EventType.FSERVER_ZK_ENTITYGROUP_FAILED_OPEN,
rt.getEventType());
}
代码示例来源:origin: alibaba/wasp
@Test
public void testFailedUpdateMeta() throws Exception {
Server server = new MockServer(WTU);
FServerServices rsServices = new MockFServerServices();
// Create it OFFLINE, which is what it expects
ZKAssign.createNodeOffline(server.getZooKeeper(), TEST_EGI,
server.getServerName());
// Create the handler
OpenEntityGroupHandler handler = new OpenEntityGroupHandler(server,
rsServices, TEST_EGI, TEST_FTD) {
@Override
boolean updateMeta(final EntityGroup e) {
// Fake failure of updating META
return false;
}
};
handler.process();
// Handler should have transitioned it to FAILED_OPEN
EntityGroupTransaction rt = EntityGroupTransaction.parseFrom(ZKAssign
.getData(server.getZooKeeper(), TEST_EGI.getEncodedName()));
assertEquals(EventType.FSERVER_ZK_ENTITYGROUP_FAILED_OPEN,
rt.getEventType());
}
}
代码示例来源:origin: alibaba/wasp
+ stats);
EntityGroupTransaction rtd = EntityGroupTransaction.parseFrom(ZKAssign
.getData(zkw, egi.getEncodedName()));
代码示例来源:origin: alibaba/wasp
/**
* Test if the entityGroup can be closed properly
*
* @throws java.io.IOException
* @throws org.apache.zookeeper.KeeperException.NodeExistsException
* @throws org.apache.zookeeper.KeeperException
* @throws com.alibaba.wasp.DeserializationException
*/
@Test
public void testCloseEntityGroup() throws IOException, NodeExistsException,
KeeperException, DeserializationException {
final Server server = new MockServer(WTU);
final MockFServerServices rss = new MockFServerServices();
FTable htd = TEST_FTD;
EntityGroupInfo egi = TEST_EGI;
openEntityGroup(server, rss, htd, egi);
int versionOfClosingNode = ZKAssign.createNodeClosing(
server.getZooKeeper(), egi, server.getServerName());
CloseEntityGroupHandler handler = new CloseEntityGroupHandler(server, rss,
egi, false, true, versionOfClosingNode,
EventType.M_FSERVER_CLOSE_ENTITYGROUP);
handler.process();
EntityGroupTransaction rt = EntityGroupTransaction.parseFrom(ZKAssign
.getData(server.getZooKeeper(), egi.getEncodedName()));
assertTrue(rt.getEventType()
.equals(EventType.FSERVER_ZK_ENTITYGROUP_CLOSED));
}
代码示例来源:origin: alibaba/wasp
/**
* Test if close entityGroup can handle ZK closing node version mismatch
*
* @throws java.io.IOException
* @throws org.apache.zookeeper.KeeperException.NodeExistsException
* @throws org.apache.zookeeper.KeeperException
* @throws com.alibaba.wasp.DeserializationException
*/
@Test
public void testZKClosingNodeVersionMismatch() throws IOException,
NodeExistsException, KeeperException, DeserializationException {
final Server server = new MockServer(WTU);
final MockFServerServices rss = new MockFServerServices();
FTable ftd = TEST_FTD;
final EntityGroupInfo egi = TEST_EGI;
// open a entityGroup first so that it can be closed later
openEntityGroup(server, rss, ftd, egi);
int versionOfClosingNode = ZKAssign.createNodeClosing(
server.getZooKeeper(), egi, server.getServerName());
CloseEntityGroupHandler handler = new CloseEntityGroupHandler(server, rss,
egi, false, true, versionOfClosingNode + 1,
EventType.M_FSERVER_CLOSE_ENTITYGROUP);
handler.process();
EntityGroupTransaction rt = EntityGroupTransaction.parseFrom(ZKAssign
.getData(server.getZooKeeper(), egi.getEncodedName()));
assertTrue(rt.getEventType().equals(EventType.M_ZK_ENTITYGROUP_CLOSING));
}
内容来源于网络,如有侵权,请联系作者删除!