From 4fd1085aa7865a2c263bd03c7fdcfd9ae7889f60 Mon Sep 17 00:00:00 2001 From: Dexter Lowe Date: Tue, 8 Sep 2015 16:37:12 +0100 Subject: [PATCH 01/11] Fixed imports to enable compilation --- .gitignore | 11 +++++++++++ src/main/java/com/d2fn/guano/DumpJob.java | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bc27e6c --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +.project +.settings +/target +.checkstyle +.idea +*.iml +/vagrant/.vagrant +/vagrant/ansible +.classpath +/bin + diff --git a/src/main/java/com/d2fn/guano/DumpJob.java b/src/main/java/com/d2fn/guano/DumpJob.java index 488272e..b97f6a4 100644 --- a/src/main/java/com/d2fn/guano/DumpJob.java +++ b/src/main/java/com/d2fn/guano/DumpJob.java @@ -1,11 +1,13 @@ package com.d2fn.guano; -import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.Watcher; import org.apache.zookeeper.ZooKeeper; import org.apache.zookeeper.data.Stat; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; import java.util.List; /** From 955fc79993b62723f4640a0d0520697cb172dea8 Mon Sep 17 00:00:00 2001 From: Dexter Lowe Date: Tue, 8 Sep 2015 16:51:07 +0100 Subject: [PATCH 02/11] Improved readme --- readme.md | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 9fa77fc..f69b32c 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,18 @@ - usage: guano +NAME + dd -- convert and copy a file - -s,--server the zookeeper remote server to connect to (ie - "localhost:2181" +SYNOPSIS + dd [operands ...] + +DESCRIPTION + This tool dumps and restores zookeeper state to/from a matching folder structure on disk. + The server argument is mandatory then either a node to dump and where to dump it, + or a previous dump to restore and the root to restore it to. + + usage: guano [-v] -s [-d -o ] [-r -i ] + + -s,--server *Required, the zookeeper remote server to connect to + i.e. "localhost:2181" -d,--dump-znode the znode to dump (recursively) -o,--output-dir the output directory to which znode @@ -14,3 +25,8 @@ restored -v,--verbose enable debug output + + Note: When restoring you need to provide one level up as the node selected for the dump is included. + e.g. java -jar target/guano-0.1a.jar -s "zookeeper-01.mydomain.com" -o "/tmp/zkdump" -d "/myroot" + java -jar target/guano-0.1a.jar -s "zookeeper-01.mydomain.com" -i "/tmp/zkdump" -r "/" + From 681cce0bec307da10fb7b53caef5c7b4e1f443dc Mon Sep 17 00:00:00 2001 From: Dexter Date: Thu, 14 Jan 2016 15:51:42 +0000 Subject: [PATCH 03/11] Fix mistakes in the readme thanks to @olibye for pointing out the mistakes --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index f69b32c..3cea91b 100644 --- a/readme.md +++ b/readme.md @@ -1,8 +1,8 @@ NAME - dd -- convert and copy a file + guano -- dump or restore Zookeeper trees SYNOPSIS - dd [operands ...] + guano [operands ...] DESCRIPTION This tool dumps and restores zookeeper state to/from a matching folder structure on disk. From 358ed4d2f9452ed2fc980eebd4c9e7efc9be5ad7 Mon Sep 17 00:00:00 2001 From: Dexter Date: Thu, 14 Jan 2016 15:53:45 +0000 Subject: [PATCH 04/11] Improved formatting --- readme.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/readme.md b/readme.md index 3cea91b..f918c35 100644 --- a/readme.md +++ b/readme.md @@ -1,10 +1,13 @@ NAME + guano -- dump or restore Zookeeper trees SYNOPSIS + guano [operands ...] DESCRIPTION + This tool dumps and restores zookeeper state to/from a matching folder structure on disk. The server argument is mandatory then either a node to dump and where to dump it, or a previous dump to restore and the root to restore it to. From 4d9c4283618985521bd45107a5c05257a8e110c1 Mon Sep 17 00:00:00 2001 From: Dexter Date: Thu, 22 Sep 2016 14:39:42 +0100 Subject: [PATCH 05/11] Added download badge for bintray Added download badge for the pre-built binaries hosted on bintray --- readme.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/readme.md b/readme.md index f918c35..ea293f1 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,5 @@ +[ ![Download](https://api.bintray.com/packages/feldoh/Guano/guano/images/download.svg) ](https://bintray.com/feldoh/Guano/guano/_latestVersion) + NAME guano -- dump or restore Zookeeper trees @@ -32,4 +34,7 @@ DESCRIPTION Note: When restoring you need to provide one level up as the node selected for the dump is included. e.g. java -jar target/guano-0.1a.jar -s "zookeeper-01.mydomain.com" -o "/tmp/zkdump" -d "/myroot" java -jar target/guano-0.1a.jar -s "zookeeper-01.mydomain.com" -i "/tmp/zkdump" -r "/" + +PREBUILT BINARIES + Pre-built binaries are available for most common platforms on Bintray From 64913da77b389ac8b3a5871c0d8e291e87360338 Mon Sep 17 00:00:00 2001 From: Dexter Date: Fri, 23 Sep 2016 16:51:26 +0000 Subject: [PATCH 06/11] Add travis integration adding travis.yml to build new commits --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d8c3222 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,2 @@ +language: java +script: mvn clean verify From dbec10d7795362cd056c8c9f5e399b83cdc414a8 Mon Sep 17 00:00:00 2001 From: Dexter Date: Fri, 23 Sep 2016 16:55:09 +0000 Subject: [PATCH 07/11] Add build status badge --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index ea293f1..84cb2d4 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -[ ![Download](https://api.bintray.com/packages/feldoh/Guano/guano/images/download.svg) ](https://bintray.com/feldoh/Guano/guano/_latestVersion) +[ ![Download](https://api.bintray.com/packages/feldoh/Guano/guano/images/download.svg) ](https://bintray.com/feldoh/Guano/guano/_latestVersion) [![Build Status](https://travis-ci.org/feldoh/guano.svg?branch=master)](https://travis-ci.org/feldoh/guano) NAME From 389f3ec2c6d68fb01dfceb00ba4606b87676dd7a Mon Sep 17 00:00:00 2001 From: Dexter Date: Fri, 23 Sep 2016 16:59:28 +0000 Subject: [PATCH 08/11] Added badges section --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index 84cb2d4..141c2f8 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,5 @@ +BADGES + [ ![Download](https://api.bintray.com/packages/feldoh/Guano/guano/images/download.svg) ](https://bintray.com/feldoh/Guano/guano/_latestVersion) [![Build Status](https://travis-ci.org/feldoh/guano.svg?branch=master)](https://travis-ci.org/feldoh/guano) NAME From f3e590ccf3e3adac6ab60e16b93f3de377d7f1f6 Mon Sep 17 00:00:00 2001 From: Stephen Greenslade Date: Tue, 4 Oct 2016 12:30:49 +0100 Subject: [PATCH 09/11] Updated DumpJob to create empty folders for znodes without any data. --- src/main/java/com/d2fn/guano/DumpJob.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/d2fn/guano/DumpJob.java b/src/main/java/com/d2fn/guano/DumpJob.java index b97f6a4..d9fa4fb 100644 --- a/src/main/java/com/d2fn/guano/DumpJob.java +++ b/src/main/java/com/d2fn/guano/DumpJob.java @@ -65,8 +65,12 @@ private void dumpChild(ZooKeeper zk, String outputPath, String znodeParent, Stri // ensure parent dir is created File f = new File(outputPath); - boolean s = f.mkdirs(); - + if(!f.exists() ) { + boolean s = f.mkdirs(); + if (s) { + System.out.println("Created folder: " + outputPath); + } + } // this znode is a dir, so ensure the directory is created and build a __znode value in its dir writeZnode(zk, outputPath + "/_znode", currznode); @@ -92,6 +96,18 @@ private void writeZnode(ZooKeeper zk, String outFile, String znode) throws Excep out.flush(); out.close(); } + } else { + if (!outFile.contains("_znode") && stat.getEphemeralOwner() == 0) { + // Create an empty folder for Ephemeral nodes. + File f = new File(outFile); + if(!f.exists() ) { + boolean s = f.mkdirs(); + if (s) { + System.out.println("Created Empty folder: " + outFile); + } + } + } + } } From 0a4cd9d26ad9b8366731c921c4b882bb5a797a62 Mon Sep 17 00:00:00 2001 From: Stephen Greenslade Date: Thu, 6 Oct 2016 20:28:00 +0100 Subject: [PATCH 10/11] Updated DumpJob with feedback from pull request. - Updated comment - Refactored code to have a private createFolder method. --- src/main/java/com/d2fn/guano/DumpJob.java | 30 +++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/d2fn/guano/DumpJob.java b/src/main/java/com/d2fn/guano/DumpJob.java index d9fa4fb..0d57318 100644 --- a/src/main/java/com/d2fn/guano/DumpJob.java +++ b/src/main/java/com/d2fn/guano/DumpJob.java @@ -64,13 +64,8 @@ private void dumpChild(ZooKeeper zk, String outputPath, String znodeParent, Stri if(!children.isEmpty()) { // ensure parent dir is created - File f = new File(outputPath); - if(!f.exists() ) { - boolean s = f.mkdirs(); - if (s) { - System.out.println("Created folder: " + outputPath); - } - } + createFolder(outputPath); + // this znode is a dir, so ensure the directory is created and build a __znode value in its dir writeZnode(zk, outputPath + "/_znode", currznode); @@ -98,19 +93,24 @@ private void writeZnode(ZooKeeper zk, String outFile, String znode) throws Excep } } else { if (!outFile.contains("_znode") && stat.getEphemeralOwner() == 0) { - // Create an empty folder for Ephemeral nodes. - File f = new File(outFile); - if(!f.exists() ) { - boolean s = f.mkdirs(); - if (s) { - System.out.println("Created Empty folder: " + outFile); - } - } + // Create an empty folder for Permanent nodes. + createFolder(outFile); } } } + private void createFolder(String path) { + File f = new File(path); + if(!f.exists() ) { + boolean s = f.mkdirs(); + if (s) { + System.out.println("Created folder: " + path); + } + } + + } + @Override public void process(WatchedEvent watchedEvent) { ;; From bd95042f8d7485aebc8a421202b2dcdb44467be5 Mon Sep 17 00:00:00 2001 From: f1yegor Date: Sat, 3 Dec 2016 15:20:51 +0100 Subject: [PATCH 11/11] bump up zookeeper to 3.4.9 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index e44a1ec..5ef3a36 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ commons-cli commons-cli - 1.2 + 1.3.1 org.apache.commons @@ -23,7 +23,7 @@ org.apache.zookeeper zookeeper - 3.4.3 + 3.4.9 com.sun.jmx