ZooKeeper recursive watcher

If you need to set up a recursive watchers (watch on all nodes), the standard ZooKeeper’s Watcher class will not help much – it is installed on only 1 node (or one-level-forward when you calling getChildren()), and is also a one-time event. This means that after each watch trigger, you need to install a new […]

READ MORE

How ZooKeeper ACL works

In this post I will describe the basic principles of how ACL works in ZooKeeper. ACL is not set recursively and is not inherited by the child nodes. If we have a read-only ACL for /path1/path2 or /path1/path2/path3, then deleting /path1 will fail, regardless of AСL of /path1. Several ACL records can be set on […]

READ MORE

Perform some action when spec fails in Spock Framework

Let’s imagine that we need to perform a certain sequence of actions when a spec fails. If you just need to close some resources when spec fails – don’t reinvent the wheel and use an easy and correct method – @AutoCleanup annotation. I wrote about it in detail earlier: https://mchesnavsky.tech/closing-resources-in-spock-framework. Keep in mind that in […]

READ MORE

Closing resources in Spock Framework

If we have any resource and we need to close it when current spec fails or done (for example, ZooKeeper client), the easiest way is to use the @AutoCleanup annotation with the resource: By default, it calls the close() method, but you can put your own: And optionally use quiet mode, when Spock Framework are going […]

READ MORE

Apache Atlas – Building & Installing

Let’s say we want to got working Apache Atlas instance with embedded Hbase & Solr on our machine. Notice, that you need to install JDK 8 before start. Go to the Apache Atlas GitHub page, and download the zip file with the source code of the latest stable release from here: https://github.com/apache/atlas/tags Important notice: DO […]

READ MORE

How to add files to META-INF with Maven

Suppose you need to add some_dir/your_file.txt to META-INF using Maven, so that the final path looks like this: To do this, you need to create a META-INF/some_dir folders in the src/main/resources directory, and put there your_file.txt file: Once compiled, Maven will move META-INF/some_dir/your_file.txt from resources to the right place without deleting the existing files in […]

READ MORE

Get Maven artifact version at runtime

Let’s imagine that we need to get the value of a certain Maven property in Java code. First, let’s create a text file with any name, for example version.txt in the src/main/resources folder: Now let’s add the following block to pom.xml: Now, when building, Maven will replace the construction ${project.version} in the file with the […]

READ MORE

How to immediately terminate the Spring Boot Yarn container with an error

Imagine an error or exception occurs while running the Spring Boot Yarn container, and we need to kill container from itself and return an error code. You can use @OnContainerStart annotation as mentioned in this article: https://mchesnavsky.tech/how-to-set-up-exit-code-on-spring-boot-yarn-container. But if we need to stop the container immediately, we just need to call: – where parameter is […]

READ MORE

NoClassDefFound Error: Could not initialize class

Suppose that you are faced with an exception like this: At first, you might think that java cannot find com.example.YourClass. But if you execute this line: Then it will work successfully and you will not see an exception. The point is that java sees the class, but a masked error occurred while initializing static fields […]

READ MORE