- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.apache.hadoop.hbase.zookeeper.ZKUtil.setData()
方法的一些代码示例,展示了ZKUtil.setData()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZKUtil.setData()
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.zookeeper.ZKUtil
类名称:ZKUtil
方法名:setData
[英]Sets the data of the existing znode to be the specified data. The node must exist but no checks are done on the existing data or version.
If the node does not exist, a NoNodeException will be thrown.
No watches are set but setting data will trigger other watchers of this node.
If there is another problem, a KeeperException will be thrown.
[中]将现有znode的数据设置为指定的数据。节点必须存在,但不检查现有数据或版本。
如果该节点不存在,则会引发NoNodeException。
未设置手表,但设置数据将触发此节点的其他手表。
如果还有其他问题,将抛出KeeperException。
代码示例来源:origin: apache/hbase
/**
* Sets the data of the existing znode to be the specified data. The node
* must exist but no checks are done on the existing data or version.
*
* <p>If the node does not exist, a {@link NoNodeException} will be thrown.
*
* <p>No watches are set but setting data will trigger other watchers of this
* node.
*
* <p>If there is another problem, a KeeperException will be thrown.
*
* @param zkw zk reference
* @param znode path of node
* @param data data to set for node
* @throws KeeperException if unexpected zookeeper exception
*/
public static void setData(ZKWatcher zkw, String znode, byte [] data)
throws KeeperException, KeeperException.NoNodeException {
setData(zkw, (SetData)ZKUtilOp.setData(znode, data));
}
代码示例来源:origin: apache/hbase
private static void processSequentially(ZKWatcher zkw, List<ZKUtilOp> ops)
throws KeeperException, NoNodeException {
for (ZKUtilOp op : ops) {
if (op instanceof CreateAndFailSilent) {
createAndFailSilent(zkw, (CreateAndFailSilent) op);
} else if (op instanceof DeleteNodeFailSilent) {
deleteNodeFailSilent(zkw, (DeleteNodeFailSilent) op);
} else if (op instanceof SetData) {
setData(zkw, (SetData) op);
} else {
throw new UnsupportedOperationException("Unexpected ZKUtilOp type: "
+ op.getClass().getName());
}
}
}
代码示例来源:origin: apache/hbase
@Override
public void setPeerState(String peerId, boolean enabled) throws ReplicationException {
byte[] stateBytes = enabled ? ENABLED_ZNODE_BYTES : DISABLED_ZNODE_BYTES;
try {
ZKUtil.setData(zookeeper, getPeerStateNode(peerId), stateBytes);
} catch (KeeperException e) {
throw new ReplicationException("Unable to change state of the peer with id=" + peerId, e);
}
}
代码示例来源:origin: apache/hbase
/**
* Set data into node creating node if it doesn't yet exist.
* Does not set watch.
*
* @param zkw zk reference
* @param znode path of node
* @param data data to set for node
* @throws KeeperException if a ZooKeeper operation fails
*/
public static void createSetData(final ZKWatcher zkw, final String znode, final byte [] data)
throws KeeperException {
if (checkExists(zkw, znode) == -1) {
ZKUtil.createWithParents(zkw, znode, data);
} else {
ZKUtil.setData(zkw, znode, data);
}
}
代码示例来源:origin: apache/hbase
@Override
public void updatePeerConfig(String peerId, ReplicationPeerConfig peerConfig)
throws ReplicationException {
try {
ZKUtil.setData(this.zookeeper, getPeerNode(peerId),
ReplicationPeerConfigUtil.toByteArray(peerConfig));
} catch (KeeperException e) {
throw new ReplicationException(
"There was a problem trying to save changes to the " + "replication peer " + peerId, e);
}
}
代码示例来源:origin: apache/hbase
/**
* Set the switch on/off
* @param enabled switch enabled or not?
* @throws KeeperException keepException will be thrown out
*/
public void setSwitchEnabled(boolean enabled) throws KeeperException {
byte [] upData = toByteArray(enabled);
try {
ZKUtil.setData(watcher, node, upData);
} catch(KeeperException.NoNodeException nne) {
ZKUtil.createAndWatch(watcher, node, upData);
}
super.nodeDataChanged(node);
}
代码示例来源:origin: apache/hbase
/**
* Sets the cluster as up.
* @throws KeeperException unexpected zk exception
*/
public void setClusterUp()
throws KeeperException {
byte [] upData = toByteArray();
try {
ZKUtil.createAndWatch(watcher, watcher.getZNodePaths().clusterStateZNode, upData);
} catch(KeeperException.NodeExistsException nee) {
ZKUtil.setData(watcher, watcher.getZNodePaths().clusterStateZNode, upData);
}
}
代码示例来源:origin: apache/hbase
private static void setData(ZKWatcher zkw, SetData setData)
throws KeeperException, KeeperException.NoNodeException {
SetDataRequest sd = (SetDataRequest)toZooKeeperOp(zkw, setData).toRequestRecord();
setData(zkw, sd.getPath(), sd.getData(), sd.getVersion());
}
代码示例来源:origin: apache/hbase
/**
* Set region normalizer on/off
* @param normalizerOn whether normalizer should be on or off
* @throws KeeperException if a ZooKeeper operation fails
*/
public void setNormalizerOn(boolean normalizerOn) throws KeeperException {
byte [] upData = toByteArray(normalizerOn);
try {
ZKUtil.setData(watcher, watcher.getZNodePaths().regionNormalizerZNode, upData);
} catch(KeeperException.NoNodeException nne) {
ZKUtil.createAndWatch(watcher, watcher.getZNodePaths().regionNormalizerZNode, upData);
}
super.nodeDataChanged(watcher.getZNodePaths().regionNormalizerZNode);
}
代码示例来源:origin: apache/hbase
/**
* Set the balancer on/off.
*
* @param balancerOn true if the balancher should be on, false otherwise
* @throws KeeperException if a ZooKeeper operation fails
*/
public void setBalancerOn(boolean balancerOn) throws KeeperException {
byte [] upData = toByteArray(balancerOn);
try {
ZKUtil.setData(watcher, watcher.getZNodePaths().balancerZNode, upData);
} catch(KeeperException.NoNodeException nne) {
ZKUtil.createAndWatch(watcher, watcher.getZNodePaths().balancerZNode, upData);
}
super.nodeDataChanged(watcher.getZNodePaths().balancerZNode);
}
代码示例来源:origin: apache/hbase
@Override
protected Pair<Long, Integer> getLastSequenceIdWithVersion(String encodedRegionName,
String peerId) throws KeeperException {
Pair<Long, Integer> oldPair = super.getLastSequenceIdWithVersion(encodedRegionName, peerId);
if (getLastSeqIdOpIndex < 100) {
// Let the ZNode version increase.
String path = getSerialReplicationRegionPeerNode(encodedRegionName, peerId);
ZKUtil.createWithParents(zookeeper, path);
ZKUtil.setData(zookeeper, path, ZKUtil.positionToByteArray(100L));
}
getLastSeqIdOpIndex++;
return oldPair;
}
};
代码示例来源:origin: apache/hbase
@Test
public void testTaskErr() throws Exception {
LOG.info("TestTaskErr - cleanup task node once in ERR state");
conf.setInt("hbase.splitlog.max.resubmit", 0);
slm = new SplitLogManager(master, conf);
TaskBatch batch = new TaskBatch();
String tasknode = submitTaskAndWait(batch, "foo/1");
final ServerName worker1 = ServerName.valueOf("worker1,1,1");
SplitLogTask slt = new SplitLogTask.Err(worker1);
ZKUtil.setData(zkw, tasknode, slt.toByteArray());
synchronized (batch) {
while (batch.installed != batch.error) {
batch.wait();
}
}
waitForCounter(tot_mgr_task_deleted, 0, 1, to/2);
assertTrue(ZKUtil.checkExists(zkw, tasknode) == -1);
conf.setInt("hbase.splitlog.max.resubmit", ZKSplitLogManagerCoordination.DEFAULT_MAX_RESUBMIT);
}
代码示例来源:origin: apache/hbase
@Test
public void testSetDataWithVersion() throws Exception {
ZKUtil.createWithParents(ZKW, "/s1/s2/s3");
int v0 = getZNodeDataVersion("/s1/s2/s3");
assertEquals(0, v0);
ZKUtil.setData(ZKW, "/s1/s2/s3", Bytes.toBytes(12L));
int v1 = getZNodeDataVersion("/s1/s2/s3");
assertEquals(1, v1);
ZKUtil.multiOrSequential(ZKW,
ImmutableList.of(ZKUtilOp.setData("/s1/s2/s3", Bytes.toBytes(13L), v1)), false);
int v2 = getZNodeDataVersion("/s1/s2/s3");
assertEquals(2, v2);
}
代码示例来源:origin: apache/hbase
@Test
public void testTaskDone() throws Exception {
LOG.info("TestTaskDone - cleanup task node once in DONE state");
slm = new SplitLogManager(master, conf);
TaskBatch batch = new TaskBatch();
String tasknode = submitTaskAndWait(batch, "foo/1");
final ServerName worker1 = ServerName.valueOf("worker1,1,1");
SplitLogTask slt = new SplitLogTask.Done(worker1);
ZKUtil.setData(zkw, tasknode, slt.toByteArray());
synchronized (batch) {
while (batch.installed != batch.done) {
batch.wait();
}
}
waitForCounter(tot_mgr_task_deleted, 0, 1, to/2);
assertTrue(ZKUtil.checkExists(zkw, tasknode) == -1);
}
代码示例来源:origin: apache/hbase
@Test
public void testWorkerCrash() throws Exception {
slm = new SplitLogManager(master, conf);
TaskBatch batch = new TaskBatch();
String tasknode = submitTaskAndWait(batch, "foo/1");
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);
// Not yet resubmitted.
Assert.assertEquals(0, tot_mgr_resubmit.sum());
// This server becomes dead
Mockito.when(sm.isServerOnline(worker1)).thenReturn(false);
Thread.sleep(1300); // The timeout checker is done every 1000 ms (hardcoded).
// It has been resubmitted
Assert.assertEquals(1, tot_mgr_resubmit.sum());
}
代码示例来源:origin: apache/hbase
private void updateZooKeeper(TableState tableState) throws IOException {
if (tableState == null) {
return;
}
String znode = ZNodePaths.joinZNode(this.master.getZooKeeper().getZNodePaths().tableZNode,
tableState.getTableName().getNameAsString());
try {
// Make sure znode exists.
if (ZKUtil.checkExists(this.master.getZooKeeper(), znode) == -1) {
ZKUtil.createAndFailSilent(this.master.getZooKeeper(), znode);
}
// Now set newState
ZooKeeperProtos.DeprecatedTableState.Builder builder =
ZooKeeperProtos.DeprecatedTableState.newBuilder();
builder.setState(
ZooKeeperProtos.DeprecatedTableState.State.valueOf(tableState.getState().toString()));
byte[] data = ProtobufUtil.prependPBMagic(builder.build().toByteArray());
ZKUtil.setData(this.master.getZooKeeper(), znode, data);
} catch (KeeperException e) {
// Only hbase1 clients suffer if this fails.
LOG.warn("Failed setting table state to zookeeper mirrored for hbase-1.x clients", e);
}
}
代码示例来源: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 testRescanCleanup() throws Exception {
LOG.info("TestRescanCleanup - ensure RESCAN nodes are cleaned up");
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());
waitForCounter(tot_mgr_heartbeat, 0, 1, to/2);
waitForCounter(new Expr() {
@Override
public long eval() {
return (tot_mgr_resubmit.sum() + tot_mgr_resubmit_failed.sum());
}
}, 0, 1, 5*60000); // wait long enough
Assert.assertEquals("Could not run test. Lost ZK connection?", 0, tot_mgr_resubmit_failed.sum());
int version1 = ZKUtil.checkExists(zkw, tasknode);
assertTrue(version1 > version);
byte[] taskstate = ZKUtil.getData(zkw, tasknode);
slt = SplitLogTask.parseFrom(taskstate);
assertTrue(slt.isUnassigned(master.getServerName()));
waitForCounter(tot_mgr_rescan_deleted, 0, 1, to/2);
}
代码示例来源: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()));
}
我正在使用 Heatmap.js 库在 Google map 上创建 map 叠加层。只要我在标签中对数据进行硬编码,它就可以很好地工作。 var myLatlng = new google.map
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 8 年前。 Improve t
我知道我们应该使用setData()来更新图表的系列, 但我不知道在创建某些柱形图时如何更新该系列,因为它的系列如下所示 series: [{ name: 'Tokyo',
我正在使用 series[0].setData() 函数使用按钮更改 High Charts 图表上的系列。它确实更改了数据并更新了图表,但是当我尝试使用第二个按钮来重置我的后台数据时,似乎什么也没有
我想用两行设置我的条形数据。 不可能用 \n 来做到这一点。 我使用 MPAndroidChart 版本 v2.2.4。 我用这段代码尝试过: Bar1 = new BarEntry(20f,0,"2
我有一张 Mapbox GL map ,其中有一个图层和该图层上的多个标记,我正在尝试更新特定标记,因此我使用 setData 来仅更新一个标记,但 setData 会将整个图层标记重置为仅添加一点,
我在使用 jquery-flot(flotcharts)制作实时图表时遇到麻烦。 这是我的代码: $(document).ready(function(){ var test = function()
我没有发现这两个函数有任何区别。 使用以下 JavaScript 代码: var x = {}; $(x).bind({ setData: function (event, key, value)
我正在尝试创建一个饼图,我可以通过一个按钮在两个数据系列之间切换。 当我将值直接传递给按钮 onclick 事件上的 setData() 函数时,一切正常。参见 jsfiddle (在职的)。 但是如
当CKEditor图像中的设置数据在编辑器区域消失时。链接和其他格式都可以,所以看起来不像双引号。另外,我尝试了绝对定位和外部图像,所以这不是找不到图像的问题。 这是我的代码: function ge
我使用新版本的 CKEditor。我面临的问题是额外的段落或 当我这样做时,在数据周围添加标签 setData 。我这样做是这样的: editor.setData(editor.getData()+'
我在 JSP 页面中定义了以下文本区域: 在我的 js 文件中,我设置内容数据如下: CKEDITOR.instances.edit_subtaskstep_notes.setData("Hello
我目前正在尝试在从文件加载后使用 SetData<> 在 Texture2D 对象上手动设置纹理数据。已在启用 MipMap 的情况下创建 Texture2D。数据已从使用 DXT1 压缩保存的 .d
我正在开发我的 SMS/MMS 应用程序并使用 android 消息通知样式。我想这样做,以便当用户发送图像时,我可以使用 MessagingStyle.Message.setData(uri, mi
我已经构建了一些自定义插件,但只有一个是监听键盘的按键事件。 在代码下方,您可以看到设置事件的设置。 (这有点基本) 现在我遇到了以下问题,如果我在 instanceReady 监听器中使用 edit
我有一个 QListWidget的日历。每个QListWidgetItem在逻辑上与 Calendar 的实例相关联,这是一个属于应用程序模型端的类。 我可以使用 QListWidgetItem::s
我有一个气泡图,可以与 jQuery UI slider 一起更改图表的内容。 (“通过时间”)但是,图表上的气泡可能会按周进出图表,并且在使用 setData 更新时,它忽略任何最初不存在的新系列。
在我的 Angular 应用程序中,我正在使用 Directions api 并尝试添加从一个方向到另一个方向的路线路径。第一次发出ajax请求时,路由路径已正确创建,但从第二次开始,我看不到路由路径
我使用的是 Angular,并使用 ngModel 设置 ckeditor 的数据 - 当我们渲染时我们设置数据 editor.setData(ngModel.$viewValue); 我们尝试保留光
我正在尝试为用户上载化身到Firestore存储并返回图像URL,以将其保存为用户实例上用户的avatarUrl属性。我可以将图片成功上传到Firestore。问题与URL的接收有关。异步函数会延迟,
我是一名优秀的程序员,十分优秀!