Detailed cluster configuration for es4x

Occasionally, I found es4x and tried to write something about my original business.It is found that the development efficiency is higher than that of kotlin.What's more, I don't have to endure idea's slowness and carton anymore.However, on top of that, I found that es4x does not use setClusterManager to configure the cluster manager.Those who are familiar with vert.x know that vert.x can set up a cluster manager through setClusterManager to acquire distributed locks, distributed map s, even distributed session s...

Well, since es4x does not have an open interface to setClusterManager, is there any other way to do this?I looked through the official documentation for vert.x (I use zookeeper, other cluster managers refer to the documentation themselves)

In Using this cluster manager and Configuring this cluster manager, it is found that in classpath, as long as there is vertx-zookeeper-3.9.0.jar, it can be automatically configured through zookeeper.json.I tried this with the official vertx command.Such is the case.For this, you can download it yourself.

By looking at the es4x code, it also continues to inherit from the Laauncher of vert.x.

class ES4X extends Launcher

So the remaining question is how to put the jar of vertx-zookeeper into the esc environment.I tried es4x run-cp, but none of them worked.On this website Found inspiration.Originally, third-party jar packages needed to be added via es4x install-v.

If multiple jar packages need to be used, separate them.See Code

 public void setVendor(String vendor) {
    if (vendor != null) {
      this.vendor = new ArrayList<>();
      for (String v : vendor.split(",")) {
        // the jar lives in node_modules/.bin (rebase to the project root)
        this.vendor.add(".." + File.separator + ".." + File.separator + v);

There's so much rubbish on it.Nursery-level tutorials are now available (take zookeeper for example)

1. Get the dependent jar package of vertx-zookeeper.

Create a new blank java gradle project using idea, modify build.gradle as follows

plugins {
    id 'java'
    id 'application'

group 'org.example'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8
repositories {

dependencies {
    compile "io.vertx:vertx-zookeeper:3.9.0"
    compile ""
    testCompile group: 'junit', name: 'junit', version: '4.12'

Operate by Diagram

2. Put the lib from the zip package you unzipped into your own es4x project and generate a new es4x-launcher.jar

Then execute the command

es4x install -v  lib/animal-sniffer-annotations-1.17.jar,lib/audience-annotations-0.5.0.jar,lib/checker-qual-2.5.2.jar,lib/curator-client-2.13.0.jar,lib/curator-framework-2.13.0.jar,lib/curator-recipes-2.13.0.jar,lib/error_prone_annotations-2.2.0.jar,lib/failureaccess-1.0.1.jar,lib/guava-28.2-jre.jar,lib/j2objc-annotations-1.1.jar,lib/jline-0.9.94.jar,lib/jsr305-3.0.2.jar,lib/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar,lib/log4j-1.2.17.jar,lib/netty-3.10.6.Final.jar,lib/slf4j-api-1.7.25.jar,lib/slf4j-log4j12-1.7.21.jar,lib/untitled-1.0-SNAPSHOT.jar,lib/vertx-zookeeper-3.9.0.jar,lib/zookeeper-3.4.13.jar

For convenience, I wrote a short piece of python code.Here's also a contribution

import os

jarList = os.listdir('./lib')
jarList = ['lib/' + jar for jar in jarList]

cmd = 'es4x install -v  ' + ','.join(jarList)

3. Write zookeepr configuration and modify package.json

Create a new conf directory and generate a zookeeper.json under it

    "retry": {

Finally, modify the start in package.json to''es4x-cp=. /conf--cluster''

Another trick is to use jd-gui to see if node_modules/.bin/es4x-launcher.jar dependencies were successfully added

Tags: Programming Zookeeper JSON Java Gradle

Posted on Sat, 11 Apr 2020 10:51:39 -0700 by rowanparker