Linux – code.openark.org http://shlomi-noach.github.io/blog/ Blog by Shlomi Noach Wed, 17 Sep 2014 07:08:20 +0000 en-US hourly 1 https://wordpress.org/?v=5.3.3 32412571 zookeepercli: lightweight, powerful, controlled command line client for ZooKeeper https://shlomi-noach.github.io/blog/linux/zookeepercli-lightweight-powerful-controlled-command-line-client-for-zookeeper https://shlomi-noach.github.io/blog/linux/zookeepercli-lightweight-powerful-controlled-command-line-client-for-zookeeper#comments Wed, 17 Sep 2014 07:08:20 +0000 https://shlomi-noach.github.io/blog/?p=6980 I’m happy to announce the availability of zookeepercli: a lightweight, simple, fast and controlled command line client for ZooKeeper.

zookeepercli allows for:

  • Basic CRUD-like operations: createsetdeleteexistsgetls (aka children).
  • Extended operations: lsr (ls recursive),  creater (create recursively)
  • Well formatted and controlled output: supporting either txt or json format
  • Single, no-dependencies binary file, based on a native Go ZooKeeper library by github.com/samuel/go-zookeeper (LICENSE)

I was dissatisfied with existing command line access to ZooKeeper. Uncontrolled and noisy output as well as large footprint were among the reasons. zookeepercli overcomes the above and provides with often required powers.

Usage samples:


$ zookeepercli --servers srv-1,srv-2,srv-3 -c create /demo_only "path placeholder"
$ zookeepercli --servers srv-1,srv-2,srv-3 -c create /demo_only/key1 "value1"
$ zookeepercli --servers srv-1,srv-2,srv-3 -c create /demo_only/key2 "value2"
$ zookeepercli --servers srv-1,srv-2,srv-3 -c create /demo_only/key3 "value3"

$ zookeepercli --servers srv-1,srv-2,srv-3 -c ls /demo_only
key3
key2
key1

# Same as above, JSON format output:
$ zookeepercli --servers srv-1,srv-2,srv-3 --format=json -c ls /demo_only
["key3","key2","key1"]

$ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only/key1
$ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only/key2
$ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only/key3
$ zookeepercli --servers srv-1,srv-2,srv-3 -c delete /demo_only

# Create a path recursively (auto-generate parent directories if not exist):
$ zookeepercli --servers=srv-1,srv-2,srv-3 -c creater "/demo_only/child/key1" "val1"
$ zookeepercli --servers=srv-1,srv-2,srv-3 -c creater "/demo_only/child/key2" "val2"

$ zookeepercli --servers=srv-1,srv-2,srv-3 -c get "/demo_only/child/key1"
val1

# This path was auto generated due to recursive create:
$ zookeepercli --servers=srv-1,srv-2,srv-3 -c get "/demo_only" 
zookeepercli auto-generated

# ls recursively a path and all sub children:
$ zookeepercli --servers=srv-1,srv-2,srv-3 -c lsr "/demo_only" 
child
child/key1
child/key2 

zookeepercli is released as open source by Outbrain under the Apache 2.0 license.

Quick links:

]]>
https://shlomi-noach.github.io/blog/linux/zookeepercli-lightweight-powerful-controlled-command-line-client-for-zookeeper/feed 9 6980
Tool of the day: q https://shlomi-noach.github.io/blog/mysql/tool-of-the-day-q https://shlomi-noach.github.io/blog/mysql/tool-of-the-day-q#comments Thu, 08 Aug 2013 09:26:02 +0000 https://shlomi-noach.github.io/blog/?p=6417 If you work with command line and know your SQL, q is a great tool to use:

q allows you to query your text files or standard input with SQL. You can:

SELECT c1, COUNT(*) FROM /home/shlomi/tmp/my_file.csv GROUP BY c1

And you can:

SELECT all.c2 FROM /tmp/all_engines.txt AS all LEFT JOIN /tmp/innodb_engines.txt AS inno USING (c1, c2) WHERE inno.c3 IS NULL

And you can also combine with your favourite shell commands and tools:

grep "my_term" /tmp/my_file.txt | q "SELECT c4 FROM - JOIN /home/shlomi/static.txt USING (c1)" | xargs touch

Some of q‘s functionality (and indeed, SQL functionality) can be found in command line tools. You can use grep for pseudo WHERE filtering, or cut for projecting, but you can only get so far with cat my_file.csv | sort | uniq -c | sort -n. SQL is way more powerful for working with tabulated data, and so q makes for a great addition into one’s toolbox.

The tool is authored by my colleague Harel Ben-Attia, and is in daily use over at our company (it is in fact installed on all production servers).

It is of course free and open source (get it on GitHub, where you can also find documentation), and very easy to setup. Enjoy!

]]>
https://shlomi-noach.github.io/blog/mysql/tool-of-the-day-q/feed 4 6417
Xfce is the new Gnome 2 https://shlomi-noach.github.io/blog/linux/xfce-is-the-new-gnome-2 https://shlomi-noach.github.io/blog/linux/xfce-is-the-new-gnome-2#comments Tue, 22 Nov 2011 12:55:41 +0000 https://shlomi-noach.github.io/blog/?p=4412 I’ve recently had it with Ubuntu’s Unity.

Wait, why Unity?

Because my gdm was consuming so much CPU my laptop had its fan working non-stop. I’ve researched and tweaked and installed and removed – and finally moved to Unity to solve that. There may have been another solution, but that’s an old story now.

Thing is, that used to be Gnome 2, a great environment for a software developer. Easy keystrokes to move between your apps, intuitive mouse gestures. Unity presented with a very slick look, but a counter-productive environment. Perhaps it’s great for people opening one Firefox window and one Libre Office Writer document. It does not work as well for people with 3 different browsers, 5 terminals on 2 different desktops, eclipse with 4 separate perspectives, and Gimp, which opens up with 5 windows up front.

Unity does not handle these well at all. To invoke a new Firefox window you can’t just click on the launcher: that would just open up one of your already open windows (and the wrong one, by the way). You either have to work your way through the specific application you work with (Ctrl+N for new window), or create a special keyboard shortcut for your favorite app (e.g. Alt+Ctrl+T for new terminal, thankfully pre-defined). And, ARGGGH! So unintuitive at times! The “Show Desktop” seems to hide all windows except the very one which happens to be maximized and focused at the time (wasn’t that window the reason to show the desktop in the first place?). OK, this post is not about Unity.

The trouble is: Gnome 3 seems to be no better in some respects. Now I confess I did not spend a lot of time with it. I just did not have the patience to go through the whole deal again. But I do have people around me using it, and I get to hear their occasional ARGGGH! Comparing notes, I don’t see that it’s a better developer’s environment.

Back to Gnome 2? Not if you’ve upgraded to Ubuntu 11.10, you can’t. And, besides, no going back in Gnome.

Back to KDE? I was an avid KDE user for years, but the premature 4.0 version made me run away. Yes, I suppose it’s possible now, but I first tried Xfce.

Wow, last time I looked at Xfce it was really lightweight, with all that implies: it used to be so poor, so minimal. Today, with the very slick work from Xubuntu, it is fairly feature rich, while remaining fairly simple. In fact, it now more resembles Gnome (I mean Gnome 2, the real Gnome) than Gnome itself.

Easy enough to customize the panels. Familiar window buttons, with no funny grouping. The ordering of window buttons alphabetically is weird, to say the least; I’m missing the option of reordering it manually (why should Thunderbird always be the last one? I want it first!). But otherwise very clear an obvious; no funny behavior.

A few days of test drive with plenty of consoles, eclipse windows, firefox windows, and I can say its easy to work with. That’s all I’m asking for: an easy to work with environment!

]]>
https://shlomi-noach.github.io/blog/linux/xfce-is-the-new-gnome-2/feed 14 4412