- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKUtil.getData()
方法的一些代码示例,展示了ZKUtil.getData()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKUtil.getData()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.zookeeper.ZKUtil
类名称:ZKUtil
方法名:getData
[英]Get znode data. Does not set a watcher.
[中]获取znode数据。不会设置观察者。
代码示例来源:origin: apache/hbase
public boolean isRpcThrottleEnabled() throws IOException {
try {
byte[] upData = ZKUtil.getData(zookeeper, rpcThrottleZNode);
return upData == null || Bytes.toBoolean(upData);
} catch (KeeperException | InterruptedException e) {
throw new IOException("Failed to get rpc throttle", e);
}
}
代码示例来源:origin: apache/hbase
@Override
public boolean isPeerEnabled(String peerId) throws ReplicationException {
try {
return Arrays.equals(ENABLED_ZNODE_BYTES,
ZKUtil.getData(zookeeper, getPeerStateNode(peerId)));
} catch (KeeperException | InterruptedException e) {
throw new ReplicationException("Unable to get status of the peer with id=" + peerId, e);
}
}
代码示例来源:origin: apache/hbase
@Override
public long getWALPosition(ServerName serverName, String queueId, String fileName)
throws ReplicationException {
byte[] bytes;
try {
bytes = ZKUtil.getData(zookeeper, getFileNode(serverName, queueId, fileName));
} catch (KeeperException | InterruptedException e) {
throw new ReplicationException("Failed to get log position (serverName=" + serverName +
", queueId=" + queueId + ", fileName=" + fileName + ")", e);
}
try {
return ZKUtil.parseWALPositionFrom(bytes);
} catch (DeserializationException de) {
LOG.warn("Failed parse log position (serverName={}, queueId={}, fileName={})",
serverName, queueId, fileName);
}
// if we can not parse the position, start at the beginning of the wal file again
return 0;
}
代码示例来源:origin: apache/hbase
private static void appendPeerState(ZKWatcher zkw, String znodeToProcess, StringBuilder sb)
throws KeeperException, InvalidProtocolBufferException {
String peerState = zkw.getConfiguration().get("zookeeper.znode.replication.peers.state",
"peer-state");
int pblen = ProtobufUtil.lengthOfPBMagic();
for (String child : ZKUtil.listChildrenNoWatch(zkw, znodeToProcess)) {
if (!child.equals(peerState)) {
continue;
}
String peerStateZnode = ZNodePaths.joinZNode(znodeToProcess, child);
sb.append("\n").append(peerStateZnode).append(": ");
byte[] peerStateData;
try {
peerStateData = ZKUtil.getData(zkw, peerStateZnode);
ReplicationProtos.ReplicationState.Builder builder =
ReplicationProtos.ReplicationState.newBuilder();
ProtobufUtil.mergeFrom(builder, peerStateData, pblen, peerStateData.length - pblen);
sb.append(builder.getState().name());
} catch (IOException ipbe) {
LOG.warn("Got Exception while parsing peer: " + znodeToProcess, ipbe);
} catch (InterruptedException e) {
zkw.interruptedException(e);
return;
}
}
}
代码示例来源:origin: apache/hbase
public static String readClusterIdZNode(ZKWatcher watcher)
throws KeeperException {
if (ZKUtil.checkExists(watcher, watcher.getZNodePaths().clusterIdZNode) != -1) {
byte [] data;
try {
data = ZKUtil.getData(watcher, watcher.getZNodePaths().clusterIdZNode);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return null;
}
if (data != null) {
try {
return ClusterId.parseFrom(data).toString();
} catch (DeserializationException e) {
throw ZKUtil.convert(e);
}
}
}
return null;
}
代码示例来源:origin: apache/hbase
@Override
public void transitPeerSyncReplicationState(String peerId) throws ReplicationException {
String newStateNode = getNewSyncReplicationStateNode(peerId);
try {
byte[] data = ZKUtil.getData(zookeeper, newStateNode);
ZKUtil.multiOrSequential(zookeeper,
Arrays.asList(ZKUtilOp.setData(newStateNode, NONE_STATE_ZNODE_BYTES),
ZKUtilOp.setData(getSyncReplicationStateNode(peerId), data)),
false);
} catch (KeeperException | InterruptedException e) {
throw new ReplicationException(
"Error transiting sync replication state for peer with id=" + peerId, e);
}
}
代码示例来源:origin: apache/hbase
/**
* Get the info port of the backup master if it is available.
* Return 0 if no backup master or zookeeper is unavailable
* @param sn server name of backup master
* @return info port or 0 if timed out or exceptions
*/
public int getBackupMasterInfoPort(final ServerName sn) {
String backupZNode = ZNodePaths.joinZNode(watcher.getZNodePaths().backupMasterAddressesZNode,
sn.toString());
try {
byte[] data = ZKUtil.getData(watcher, backupZNode);
final ZooKeeperProtos.Master backup = parse(data);
if (backup == null) {
return 0;
}
return backup.getInfoPort();
} catch (Exception e) {
LOG.warn("Failed to get backup master: " + sn + "'s info port.", e);
return 0;
}
}
代码示例来源:origin: apache/hbase
@Override
public ReplicationPeerConfig getPeerConfig(String peerId) throws ReplicationException {
byte[] data;
try {
data = ZKUtil.getData(zookeeper, getPeerNode(peerId));
} catch (KeeperException | InterruptedException e) {
throw new ReplicationException("Error getting configuration for peer with id=" + peerId, e);
}
if (data == null || data.length == 0) {
throw new ReplicationException(
"Replication peer config data shouldn't be empty, peerId=" + peerId);
}
try {
return ReplicationPeerConfigUtil.parsePeerFrom(data);
} catch (DeserializationException e) {
throw new ReplicationException(
"Failed to parse replication peer config for peer with id=" + peerId, e);
}
}
代码示例来源:origin: apache/hbase
private Pair<ServerName, RegionServerInfo> getServerInfo(String name)
throws KeeperException, IOException {
ServerName serverName = ServerName.parseServerName(name);
String nodePath = ZNodePaths.joinZNode(watcher.getZNodePaths().rsZNode, name);
byte[] data;
try {
data = ZKUtil.getData(watcher, nodePath);
} catch (InterruptedException e) {
throw (InterruptedIOException) new InterruptedIOException().initCause(e);
}
if (data == null) {
// we should receive a children changed event later and then we will expire it, so we still
// need to add it to the region server set.
LOG.warn("Server node {} does not exist, already dead?", name);
return Pair.newPair(serverName, null);
}
if (data.length == 0 || !ProtobufUtil.isPBMagicPrefix(data)) {
// this should not happen actually, unless we have bugs or someone has messed zk up.
LOG.warn("Invalid data for region server node {} on zookeeper, data length = {}", name,
data.length);
return Pair.newPair(serverName, null);
}
RegionServerInfo.Builder builder = RegionServerInfo.newBuilder();
int magicLen = ProtobufUtil.lengthOfPBMagic();
ProtobufUtil.mergeFrom(builder, data, magicLen, data.length - magicLen);
return Pair.newPair(serverName, builder.build());
}
代码示例来源:origin: apache/hbase
private SyncReplicationState getSyncReplicationState(String peerId, String path)
throws ReplicationException {
try {
byte[] data = ZKUtil.getData(zookeeper, path);
if (data == null || data.length == 0) {
if (ZKUtil.checkExists(zookeeper, getPeerNode(peerId)) != -1) {
// should be a peer from previous version, set the sync replication state for it.
ZKUtil.createSetData(zookeeper, path, NONE_STATE_ZNODE_BYTES);
return SyncReplicationState.NONE;
} else {
throw new ReplicationException(
"Replication peer sync state shouldn't be empty, peerId=" + peerId);
}
}
return SyncReplicationState.parseFrom(data);
} catch (KeeperException | InterruptedException | IOException e) {
throw new ReplicationException(
"Error getting sync replication state of path " + path + " for peer with id=" + peerId, e);
}
}
代码示例来源:origin: apache/hbase
@Test
public void testZookeeperNodesForReplicas() throws Exception {
// Checks all the znodes exist when meta's replicas are enabled
ZKWatcher zkw = TEST_UTIL.getZooKeeperWatcher();
Configuration conf = TEST_UTIL.getConfiguration();
String baseZNode = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT,
HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
String primaryMetaZnode = ZNodePaths.joinZNode(baseZNode,
conf.get("zookeeper.znode.metaserver", "meta-region-server"));
// check that the data in the znode is parseable (this would also mean the znode exists)
byte[] data = ZKUtil.getData(zkw, primaryMetaZnode);
ProtobufUtil.toServerName(data);
for (int i = 1; i < 3; i++) {
String secZnode = ZNodePaths.joinZNode(baseZNode,
conf.get("zookeeper.znode.metaserver", "meta-region-server") + "-" + i);
String str = zkw.getZNodePaths().getZNodeForReplica(i);
assertTrue(str.equals(secZnode));
// check that the data in the znode is parseable (this would also mean the znode exists)
data = ZKUtil.getData(zkw, secZnode);
ProtobufUtil.toServerName(data);
}
}
代码示例来源:origin: apache/hbase
/**
* Create a znode with data
*/
@Test
public void testCreateWithParents() throws KeeperException, InterruptedException {
byte[] expectedData = new byte[] { 1, 2, 3 };
ZKUtil.createWithParents(ZKW, "/l1/l2/l3/l4/testCreateWithParents", expectedData);
byte[] data = ZKUtil.getData(ZKW, "/l1/l2/l3/l4/testCreateWithParents");
assertTrue(Bytes.equals(expectedData, data));
ZKUtil.deleteNodeRecursively(ZKW, "/l1");
ZKUtil.createWithParents(ZKW, "/testCreateWithParents", expectedData);
data = ZKUtil.getData(ZKW, "/testCreateWithParents");
assertTrue(Bytes.equals(expectedData, data));
ZKUtil.deleteNodeRecursively(ZKW, "/testCreateWithParents");
}
代码示例来源:origin: apache/hbase
/**
* Test whether the splitlog correctly creates a task in zookeeper
* @throws Exception
*/
@Test
public void testTaskCreation() throws Exception {
LOG.info("TestTaskCreation - test the creation of a task in zk");
slm = new SplitLogManager(master, conf);
TaskBatch batch = new TaskBatch();
String tasknode = submitTaskAndWait(batch, "foo/1");
byte[] data = ZKUtil.getData(zkw, tasknode);
SplitLogTask slt = SplitLogTask.parseFrom(data);
LOG.info("Task node created " + slt.toString());
assertTrue(slt.isUnassigned(master.getServerName()));
}
代码示例来源:origin: apache/hbase
@Test
public void testSimpleMulti() throws Exception {
// null multi
ZKUtil.multiOrSequential(zkw, null, false);
// empty multi
ZKUtil.multiOrSequential(zkw, new LinkedList<>(), false);
// single create
String path = ZNodePaths.joinZNode(zkw.getZNodePaths().baseZNode, "testSimpleMulti");
LinkedList<ZKUtilOp> singleCreate = new LinkedList<>();
singleCreate.add(ZKUtilOp.createAndFailSilent(path, new byte[0]));
ZKUtil.multiOrSequential(zkw, singleCreate, false);
assertTrue(ZKUtil.checkExists(zkw, path) != -1);
// single setdata
LinkedList<ZKUtilOp> singleSetData = new LinkedList<>();
byte [] data = Bytes.toBytes("foobar");
singleSetData.add(ZKUtilOp.setData(path, data));
ZKUtil.multiOrSequential(zkw, singleSetData, false);
assertTrue(Bytes.equals(ZKUtil.getData(zkw, path), data));
// single delete
LinkedList<ZKUtilOp> singleDelete = new LinkedList<>();
singleDelete.add(ZKUtilOp.deleteNodeFailSilent(path));
ZKUtil.multiOrSequential(zkw, singleDelete, false);
assertTrue(ZKUtil.checkExists(zkw, path) == -1);
}
代码示例来源:origin: apache/hbase
@BeforeClass
public static void setUp() throws Exception {
// Set up the integration test util
if (util == null) {
util = new IntegrationTestingUtility();
}
util.getConfiguration().setInt(HConstants.META_REPLICAS_NUM, 3);
util.getConfiguration().setInt(
StorefileRefresherChore.REGIONSERVER_STOREFILE_REFRESH_PERIOD, 1000);
// Make sure there are three servers.
util.initializeCluster(3);
ZKWatcher zkw = util.getZooKeeperWatcher();
Configuration conf = util.getConfiguration();
String baseZNode = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT,
HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
String primaryMetaZnode = ZNodePaths.joinZNode(baseZNode,
conf.get("zookeeper.znode.metaserver", "meta-region-server"));
// check that the data in the znode is parseable (this would also mean the znode exists)
byte[] data = ZKUtil.getData(zkw, primaryMetaZnode);
ProtobufUtil.toServerName(data);
waitUntilZnodeAvailable(1);
waitUntilZnodeAvailable(2);
}
代码示例来源:origin: apache/hbase
@Test
public void testCleanZNode() throws Exception {
ZKWatcher zkw = new ZKWatcher(TEST_UTIL.getConfiguration(),
"testNodeTracker", new TestZKNodeTracker.StubAbortable());
final ServerName sn = ServerName.valueOf("127.0.0.1:52", 45L);
ZKUtil.createAndFailSilent(zkw,
TEST_UTIL.getConfiguration().get(HConstants.ZOOKEEPER_ZNODE_PARENT,
HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT));
final String nodeName = zkw.getZNodePaths().masterAddressZNode;
// Check that we manage the case when there is no data
ZKUtil.createAndFailSilent(zkw, nodeName);
MasterAddressTracker.deleteIfEquals(zkw, sn.toString());
assertNotNull(ZKUtil.getData(zkw, nodeName));
// Check that we don't delete if we're not supposed to
ZKUtil.setData(zkw, nodeName, MasterAddressTracker.toByteArray(sn, 0));
MasterAddressTracker.deleteIfEquals(zkw, ServerName.valueOf("127.0.0.2:52", 45L).toString());
assertNotNull(ZKUtil.getData(zkw, nodeName));
// Check that we delete when we're supposed to
ZKUtil.setData(zkw, nodeName,MasterAddressTracker.toByteArray(sn, 0));
MasterAddressTracker.deleteIfEquals(zkw, sn.toString());
assertNull(ZKUtil.getData(zkw, nodeName));
// Check that we support the case when the znode does not exist
MasterAddressTracker.deleteIfEquals(zkw, sn.toString()); // must not throw an exception
}
代码示例来源:origin: apache/hbase
@Test
public void testDeadWorker() throws Exception {
LOG.info("testDeadWorker");
conf.setLong("hbase.splitlog.max.resubmit", 0);
slm = new SplitLogManager(master, conf);
TaskBatch batch = new TaskBatch();
String tasknode = submitTaskAndWait(batch, "foo/1");
int version = ZKUtil.checkExists(zkw, tasknode);
final ServerName worker1 = ServerName.valueOf("worker1,1,1");
SplitLogTask slt = new SplitLogTask.Owned(worker1);
ZKUtil.setData(zkw, tasknode, slt.toByteArray());
if (tot_mgr_heartbeat.sum() == 0) waitForCounter(tot_mgr_heartbeat, 0, 1, to/2);
slm.handleDeadWorker(worker1);
if (tot_mgr_resubmit.sum() == 0) waitForCounter(tot_mgr_resubmit, 0, 1, to+to/2);
if (tot_mgr_resubmit_dead_server_task.sum() == 0) {
waitForCounter(tot_mgr_resubmit_dead_server_task, 0, 1, to + to/2);
}
int version1 = ZKUtil.checkExists(zkw, tasknode);
assertTrue(version1 > version);
byte[] taskstate = ZKUtil.getData(zkw, tasknode);
slt = SplitLogTask.parseFrom(taskstate);
assertTrue(slt.isUnassigned(master.getServerName()));
return;
}
代码示例来源:origin: apache/hbase
@Test
public void testAcquireTaskAtStartup() throws Exception {
LOG.info("testAcquireTaskAtStartup");
SplitLogCounters.resetCounters();
final String TATAS = "tatas";
final ServerName RS = ServerName.valueOf("rs,1,1");
RegionServerServices mockedRS = getRegionServer(RS);
zkw.getRecoverableZooKeeper().create(ZKSplitLog.getEncodedNodeName(zkw, TATAS),
new SplitLogTask.Unassigned(ServerName.valueOf("mgr,1,1")).toByteArray(),
Ids.OPEN_ACL_UNSAFE,
CreateMode.PERSISTENT);
SplitLogWorker slw =
new SplitLogWorker(ds, TEST_UTIL.getConfiguration(), mockedRS, neverEndingTask);
slw.start();
try {
waitForCounter(SplitLogCounters.tot_wkr_task_acquired, 0, 1, WAIT_TIME);
byte [] bytes = ZKUtil.getData(zkw, ZKSplitLog.getEncodedNodeName(zkw, TATAS));
SplitLogTask slt = SplitLogTask.parseFrom(bytes);
assertTrue(slt.isOwned(RS));
} finally {
stopSplitLogWorker(slw);
}
}
代码示例来源:origin: apache/hbase
private TableState.State getTableStateInZK(ZKWatcher watcher, final TableName tableName)
throws KeeperException, IOException, InterruptedException {
String znode = ZNodePaths.joinZNode(watcher.getZNodePaths().tableZNode,
tableName.getNameAsString());
byte [] data = ZKUtil.getData(watcher, znode);
if (data == null || data.length <= 0) {
return null;
}
try {
ProtobufUtil.expectPBMagicPrefix(data);
ZooKeeperProtos.DeprecatedTableState.Builder builder =
ZooKeeperProtos.DeprecatedTableState.newBuilder();
int magicLen = ProtobufUtil.lengthOfPBMagic();
ProtobufUtil.mergeFrom(builder, data, magicLen, data.length - magicLen);
return TableState.State.valueOf(builder.getState().toString());
} catch (IOException e) {
KeeperException ke = new KeeperException.DataInconsistencyException();
ke.initCause(e);
throw ke;
} catch (DeserializationException e) {
throw ZKUtil.convert(e);
}
}
}
代码示例来源:origin: apache/hbase
@Test
public void testTaskResigned() throws Exception {
LOG.info("TestTaskResigned - resubmit task node once in RESIGNED state");
assertEquals(0, tot_mgr_resubmit.sum());
slm = new SplitLogManager(master, conf);
assertEquals(0, tot_mgr_resubmit.sum());
TaskBatch batch = new TaskBatch();
String tasknode = submitTaskAndWait(batch, "foo/1");
assertEquals(0, tot_mgr_resubmit.sum());
final ServerName worker1 = ServerName.valueOf("worker1,1,1");
assertEquals(0, tot_mgr_resubmit.sum());
SplitLogTask slt = new SplitLogTask.Resigned(worker1);
assertEquals(0, tot_mgr_resubmit.sum());
ZKUtil.setData(zkw, tasknode, slt.toByteArray());
ZKUtil.checkExists(zkw, tasknode);
// Could be small race here.
if (tot_mgr_resubmit.sum() == 0) {
waitForCounter(tot_mgr_resubmit, 0, 1, to/2);
}
assertEquals(1, tot_mgr_resubmit.sum());
byte[] taskstate = ZKUtil.getData(zkw, tasknode);
slt = SplitLogTask.parseFrom(taskstate);
assertTrue(slt.isUnassigned(master.getServerName()));
}
我如何在Android工作室项目中实现OneSignal时解决这个问题?
我正在从另一个电子表格中导入一个范围,然后使用此脚本将其粘贴到当前电子表格中: function getdata() { var values = SpreadsheetApp.openById('X
我正在观看来自 Slidenerd 的关于在 Android 上制作 Recycle View 的 Android 教程。这个链接:https://www.youtube.com/watch?v=Oo
public function json_product_list($where, $order){ global $_M; $this->table = load::sys_clas
我正在开发一个 Silverlight 3 应用程序,我想将所有意外错误处理委托(delegate)给一个我命名为 ErrorHandler 的类的单个实例。 .这个类有一个名为 HandleAppl
我有一个网站,允许用户进行输入并创建新内容。我总是使用tinymce 作为输入字段。今天切换到 ckeditor 后,我注意到我遇到了与最初使用 tinymce 时遇到的相同问题: 提交表单时,编辑器
我知道这个问题已经被问过几次了,但还没有一个答案真正帮助我解决我的问题。 我为三个下拉菜单设置了三个事件订阅者,它们相互依赖。 所以在我的 FormType 中我说: public functio
我无法理解如何从 short[] 获取 RGBA 值,该值是从 bufferedImage.getRaster().dataBuffer.getData() 获取的,如果 dataBuffer 是Da
#include #include #define MAX 20 #define MAX_BASE 8 #define ROW 9 #define COLUMN_SCORE 12 #define
谁能帮我理解这背后的逻辑? $(document).ready(function() { getData([renderData]); }); function renderData(JSON
我有一个类,比如“CDownloader”,它读取一些 XML 数据并提供通过节点名称的访问。它具有一些 getter 函数,如下所示: BOOL CDownloader::getInteger (
对于大学来说,我必须制作一个带有 MVC 风格编码的 JavaScript 游戏。 (模型、 View 、 Controller )。我对此很陌生,所以请不要太难。我收到以下错误:“未捕获类型错误:无
我对 Python 模块 PIL 有疑问: 每当我在图像上调用 getdata() 方法时,都会返回一些奇怪的东西。 from PIL import Image # Histogram class t
我正在使用 Texture2D.GetData()创建 Tilemap 的方法。这在我第一次执行时总是有效,但第二次该方法只是返回其他颜色,混淆了整个算法。我完全没有理由这样做。 我的代码: swit
我刚开始学习XNA/MonoGame,遇到了一个奇怪的异常。 错误提示:未实现方法或操作。 更奇怪的是,一个非常相似、几乎相同的代码却能工作。唯一的区别是其他代码在 XNA 和另一台计算机上运行,
首先,我会先说我是 javascript 的新手,所以希望这不是一个完整的脸谱问题。话虽如此,当用户点击它时,以下代码应该提醒编辑器的值。 function openEditor(){ html =
我正在使用 Monogame 将一款游戏从 XNA 转换到 iOS。 在下面的代码片段中,smallDeform 是一个 Texture2D,我在其上调用了 GetData 方法。 smallDefo
我有一个属性 cdn_image_name,它适用于大约 90 000 种产品。最近,内容编辑报告说大约有三种产品缺少图片。我已将问题确定为 Magento 的 getData() 方法。 这是与原始
byte [] r = new byte[4096]; DatagramPacket dpr = new DatagramPacket(r, r.length); sock.receive(dpr);
本文整理了Java中org.zeromq.ZFrame.getData()方法的一些代码示例,展示了ZFrame.getData()的具体用法。这些代码示例主要来源于Github/Stackoverf
我是一名优秀的程序员,十分优秀!