getData() in CuratorFramework not returning any data - apache-zookeeper

When I run
get <path>
in zookeepr CLI, I get the following
192.168.0.102
cZxid = 0x2e93
ctime = Wed Feb 06 15:12:20 GMT+05:30 2013
mZxid = 0x2e93
mtime = Wed Feb 06 15:12:20 GMT+05:30 2013
pZxid = 0x2e93
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x13cae2a97ed001f
dataLength = 13
numChildren = 0
For the same path I am trying to get the data as follow
client.getData().forPath(path);
I deserialize the data. But it is not returning anything.
I also tried
client.getData().inBackround().forPath(path);
client.getData().watched().inBackGround().forPath(path);

It's because you are using inBackground().
inBackground() causes the request to execute asynchronously. By removing inBackground() you should get the desired outcome.

Related

how can zookeeper cli create an empty node?

The create command:
create [-s] [-e] path data
Unspecified the data field while creating node.
It is possible using ZooInspector
I have used the following command: create /test "".
Get command on zkCli results:
[zk: localhost:2181(CONNECTED) 14] get /test
cZxid = 0x4
ctime = Fri Sep 07 09:38:31 IRDT 2018
mZxid = 0x4
mtime = Fri Sep 07 09:38:31 IRDT 2018
pZxid = 0x4
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 0
numChildren = 0
Finally, I download the zooInspector to check how it works and I create two znodes: fromcli and fromInspector. Accordingly, results are presented:
[zk: localhost:2181(CONNECTED) 20] ls /
[fromInspector, zookeeper, fromcli]
[zk: localhost:2181(CONNECTED) 21] get /fromcli
cZxid = 0x23
ctime = Fri Sep 07 11:11:39 IRDT 2018
mZxid = 0x23
mtime = Fri Sep 07 11:11:39 IRDT 2018
pZxid = 0x23
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 0
numChildren = 0
[zk: localhost:2181(CONNECTED) 22] get /fromInspector
cZxid = 0x24
ctime = Fri Sep 07 11:12:01 IRDT 2018
mZxid = 0x24
mtime = Fri Sep 07 11:12:01 IRDT 2018
pZxid = 0x24
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 0
numChildren = 0

Google App Script formatted date Match in Array without iterating

I am trying to find the first occurrence of a date, happens to be in 'MMM dd" format, within a coloumn, by using findIndex method.
The following code isnt able to achieve it
function copyInvoiceDetailsToDB() {
var sss = SpreadsheetApp.getActiveSpreadsheet();
var ss = sss.getSheetByName('Import MT Order Sheet'); //Source Sheet
var compareDate = ss.getRange(1,4).getValue(); // Search item
///var mmm = Utilities.formatDate(compareDate,"IST", 'MMM dd');
var reldata = ss.getRange('A3:AA'+ a).getValues();
var tss = SpreadsheetApp.openById("1xhPD6tlJiU33_tdnC82p-
e9rWA8mmMtI0g9jDLkk6s0"); // sheet being searched
var ss = tss.getSheetByName('DB');
var ssdata = ss.getRange('A:A').getValues(); // Range containing the values
var a = ssdata.indexOf(compareDate);
Logger.log(a);
Logger.log(compareDate);
Logger.log(ssdata);
return;
Generates the following log.
Please help me understand where I must be going wrong.
[17-11-22 02:40:11:568 IST] -1.0
[17-11-22 02:40:11:569 IST] Nov 22
[17-11-22 02:40:11:572 IST] [[], [Sun Nov 19 00:00:00 GMT+05:30 2017], [Mon Nov 20 00:00:00 GMT+05:30 2017], [Mon Nov 20 00:00:00 GMT+05:30 2017], [Mon Nov 20 00:00:00 GMT+05:30 2017], [Tue Nov 21 00:00:00 GMT+05:30 2017], [Tue Nov 21 00:00:00 GMT+05:30 2017], [Wed Nov 22 00:00:00 GMT+05:30 2017], [Wed Nov 22 00:00:00 GMT+05:30 2017], [Wed Nov 22 00:00:00 GMT+05:30 2017], [Wed Nov 22 00:00:00 GMT+05:30 2017], [Wed Nov 22 00:00:00 GMT+05:30 2017], [Wed Nov 22 00:00:00 GMT+05:30 2017], [Wed Nov 22 00:00:00 GMT+05:30 2017], [Wed Nov 22 00:00:00 GMT+05:30 2017], [Wed Nov 22 00:00:00
How about this answer? From your question, I understood as follows.
You want to retrieve the first occurrence (the row number?) of a date using a string 'MMM dd".
You want to understand for retrieving values using indexOf().
About retrieving values from array using indexOf()
When you want to retrieve a value from an array using indexOf(), the array has to be 1 dimensional array. This is pointed out by Sandy Good.
When a value is retrieved from an 1 dimensional array using indexOf(), it doesn't retrieve the value included in each element, it retrieves the same value for each element.
["foo", "bar", "baz"].indexOf("ba") is -1.
This means that there is no "ba" in each element in the array.
["foo", "bar", "baz"].indexOf("bar") is 1.
This means that there is "bar" at index 1 of the array.
When it retrieves the value included in each element, each element has to be used as a string.
["foo", "bar", "baz"].indexOf("ba") is -1.
"bar".indexOf("ba") is 0.
This means that the string of "ba" is found at 1st string in "bar". So in the case of "bbbar".indexOf("ba"), the result is 2.
The modification point reflected them is as follows.
Modification point :
From :
var a = ssdata.indexOf(compareDate);
Logger.log(a);
To :
var a;
for (var i in ssdata) {
if (ssdata[i][0].indexOf(compareDate) > -1) {
a = i;
break;
}
}
Logger.log(a);
a is the index with the value included "Nov 22" in the array of ssdata. If you want to the row number, please add 1 to it.
When your result shown at the log is used, a is 7.
References :
Array.prototype.indexOf()
String.prototype.indexOf()
If I misunderstand your question, I'm sorry.

Why root directory node does not exist while nodes under root directory exist in zookeeper instance?

I am running a zookeeper instance aka IA in standalone mode, trying to upgrade to quorum mode, then I prepared another 2 zookeeper instances(IB and IC) with empty snapshot directory, first modified zoo.cfg properly in 3 instances, and created myid respectively, restart the standalone instance IA first, then start the other 2.
What happened to IB and IC is, they have the data, but the root directory is not there:
Both IB and IC:
[zk: localhost:2181(CONNECTED) 14] ls /
Node does not exist: /
[zk: localhost:2181(CONNECTED) 15] ls /zookeeper
[quota]
[zk: localhost:2181(CONNECTED) 16]
besides, there is data loss in IB:
[zk: localhost:2181(CONNECTED) 16] get /demo/version
cZxid = 0x30000006c
ctime = Thu Dec 22 17:49:13 CST 2016
mZxid = 0x30000006c
mtime = Thu Dec 22 17:49:13 CST 2016
pZxid = 0x6003792a0
cversion = 12764622
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 0
numChildren = 135794
[zk: localhost:2181(CONNECTED) 17]
IA looks like:
[zk: localhost:2181(CONNECTED) 10] get /demo/version
cZxid = 0x30000006c
ctime = Thu Dec 22 17:49:13 CST 2016
mZxid = 0x30000006c
mtime = Thu Dec 22 17:49:13 CST 2016
pZxid = 0x6003792a0
cversion = 12312921
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 0
numChildren = 587495
[zk: localhost:2181(CONNECTED) 11]
IC looks like:
[zk: localhost:2181(CONNECTED) 10] get /demo/version
cZxid = 0x30000006c
ctime = Thu Dec 22 17:49:13 CST 2016
mZxid = 0x30000006c
mtime = Thu Dec 22 17:49:13 CST 2016
pZxid = 0x6003792a0
cversion = 12312921
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 0
numChildren = 587495
[zk: localhost:2181(CONNECTED) 11]
btw, the status are just fine:
IA:
[shell#kernel /data/zookeeper/zookeeper-3.4.8/bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /data/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
Mode: follower
IB:
[shell#kernel /data/zookeeper/zookeeper-3.4.8/bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /data/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
Mode: follower
IC:
[shell#kernel /data/zookeeper/zookeeper-3.4.8/bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /data/zookeeper/zookeeper-3.4.8/bin/../conf/zoo.cfg
Mode: leader
As shown above, the version is
3.4.8
Thank you in advance
I managed to fix this issue by changing the initLimit and syncLimit to 100 and 50 respectively, tickTime remains to 2000, then migrate from standalone mode to quorum mode, wait a moment, everything went fine then.

Zookeeper watches :: No notification in case of child node modification

We are seeing an issue with zookeeper watches. We creating a node “/newtest” and intent is to add/modify nodes inside it. We are putting a watch on "/newtest”. Our observation is that if a child is added or deleted we get the notification but if a child is modified we do not get the notification.
Below is the output from zkCli.sh commands
========
[zk: localhost:2181(CONNECTED) 21] ls /newtest watch <=== to get the child nodes plus the watch
[1, 5, 4] <=== 1,5, 4 are the child nodes
[zk: localhost:2181(CONNECTED) 24] set /newtest/5 hello6 <=== updating the data for node “5”, no watch notification
cZxid = 0xc16
ctime = Fri Mar 11 01:03:29 UTC 2016
mZxid = 0xc78
mtime = Fri Mar 11 01:19:48 UTC 2016
pZxid = 0xc16
cversion = 0
dataVersion = 2
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 6
numChildren = 0
[zk: localhost:2181(CONNECTED) 25] create /newtest/6 hello6 <=== creating a new node
WATCHER::
Created /newtest/6
WatchedEvent state:SyncConnected type:NodeChildrenChanged path:/newtest <== watcher notification
[zk: localhost:2181(CONNECTED) 26] ls /newtest watch <=== Again watch
[1, 6, 5, 4]
[zk: localhost:2181(CONNECTED) 27] set /newtest/6 hello6 <== updating node “6”, no notification
cZxid = 0xc79
ctime = Fri Mar 11 01:19:59 UTC 2016
mZxid = 0xc86
mtime = Fri Mar 11 01:23:18 UTC 2016
pZxid = 0xc79
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 6
numChildren = 0
========
Please suggest a solution. Zookeeper version is zookeeper.version=3.4.6--1
I would suggest not using zkCli.sh for anything other than testing and small/quick operations. If you want to get notifications when a child node is modified I would suggest writing your own watchers in Java using Apache Curator, and more specifically using a Tree Cache.

Kafka Consumer startup error: Failed to add leader for partitions [calls,0] - NotLeaderForPartitionException

Note: this is for an older version : We are running kafka_2.9.2-0.8.1
When attempting to run the kafka-console-consumer.bat against an existing topic on windows7 we receive "failed to add leader" and "NotLeaderForPartition" exceptions
Here is the command line
set GROUP=group1234
kafka-console-consumer.bat --group %GROUP% --zookeeper localhost:2181 --topic calls --from-beginning
Here are the errors:
[2014-05-26 15:02:12,997] WARN [group1234_S80035683-SC01-1401141732400-98745e28-leader-finder-thread], Failed to add leader for partitions [calls,0];
will retry (kafka.consumer.ConsumerFetcherManager$LeaderFinderThread:89)
kafka.common.NotLeaderForPartitionException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.lang.Class.newInstance(Class.java:374)
at kafka.common.ErrorMapping$.exceptionFor(ErrorMapping.scala:73)
at kafka.consumer.SimpleConsumer.earliestOrLatestOffset(SimpleConsumer.scala:160)
at kafka.consumer.ConsumerFetcherThread.handleOffsetOutOfRange(ConsumerFetcherThread.scala:60)
at kafka.server.AbstractFetcherThread$$anonfun$addPartitions$2.apply(AbstractFetcherThread.scala:179)
at kafka.server.AbstractFetcherThread$$anonfun$addPartitions$2.apply(AbstractFetcherThread.scala:174)
at scala.collection.immutable.Map$Map1.foreach(Map.scala:119)
at kafka.server.AbstractFetcherThread.addPartitions(AbstractFetcherThread.scala:174)
at kafka.server.AbstractFetcherManager$$anonfun$addFetcherForPartitions$2.apply(AbstractFetcherManager.scala:86)
at kafka.server.AbstractFetcherManager$$anonfun$addFetcherForPartitions$2.apply(AbstractFetcherManager.scala:76)
at scala.collection.immutable.Map$Map1.foreach(Map.scala:119)
at kafka.server.AbstractFetcherManager.addFetcherForPartitions(AbstractFetcherManager.scala:76)
And we are unable to consume any messages in the end.
We are running kafka_2.9.2-0.8.1
Note: Zookeeper is seeing the Consumer attempt to connect: I go into zkCli and can see the new group1234
[zk: localhost:2181(CONNECTED) 2] ls2 /consumers/group1234
[owners, ids]
cZxid = 0x123
ctime = Mon May 26 15:02:12 PDT 2014
mZxid = 0x123
mtime = Mon May 26 15:02:12 PDT 2014
pZxid = 0x128
cversion = 2
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 0
numChildren = 2
And here is info on the requested calls topic in ZK:
[zk: localhost:2181(CONNECTED) 7] ls2 /brokers/topics/calls
[partitions]
cZxid = 0x18
ctime = Sat May 24 23:15:16 PDT 2014
mZxid = 0x18
mtime = Sat May 24 23:15:16 PDT 2014
pZxid = 0x1c
cversion = 1
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 36
numChildren = 1
In case there were corruption on the topic, I just dropped it in ZK and then recreated it via kafka-topics.bat. Here is the new ZK output
[zk: localhost:2181(CONNECTED) 15] ls2 /brokers/topics/calls
[]
cZxid = 0x136
ctime = Mon May 26 16:02:51 PDT 2014
mZxid = 0x136
mtime = Mon May 26 16:02:51 PDT 2014
pZxid = 0x136
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 36
numChildren = 0
A search shows that now, 7 years later, this is no longer a known problem for current versions.
There have also been multiple patches which resolve errors that may or may not be the same, and it is almost certain that one of these fixed the issue.
As such the only practical solution for anyone seems to be upgrading to a newer version. (For Kafka, Zookeeper as well as Windows.)
If the problem persists in currently relevant versions please ask a new question as the root cause is unlikely to be the same.