GLB CTL Java Client

A Java client for the Galera Load Balancer control interface

License

License

GroupId

GroupId

ca.pjer
ArtifactId

ArtifactId

glb-ctl
Last Version

Last Version

0.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

GLB CTL Java Client
A Java client for the Galera Load Balancer control interface

Download glb-ctl

How to add to project

<!-- https://jarcasting.com/artifacts/ca.pjer/glb-ctl/ -->
<dependency>
    <groupId>ca.pjer</groupId>
    <artifactId>glb-ctl</artifactId>
    <version>0.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/ca.pjer/glb-ctl/
implementation 'ca.pjer:glb-ctl:0.0.1'
// https://jarcasting.com/artifacts/ca.pjer/glb-ctl/
implementation ("ca.pjer:glb-ctl:0.0.1")
'ca.pjer:glb-ctl:jar:0.0.1'
<dependency org="ca.pjer" name="glb-ctl" rev="0.0.1">
  <artifact name="glb-ctl" type="jar" />
</dependency>
@Grapes(
@Grab(group='ca.pjer', module='glb-ctl', version='0.0.1')
)
libraryDependencies += "ca.pjer" % "glb-ctl" % "0.0.1"
[ca.pjer/glb-ctl "0.0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

glb-ctl

A Java client for the Galera Load Balancer control interface

Warning

All of this project was done really quickly (in less than an hour) to be used in an other project. It works OK for me, but may set your computer on fire, YMMV. Use at your own risk.

Usage

In your pom.xml:

<dependency>
    <groupId>ca.pjer</groupId>
    <artifactId>glb-ctl</artifactId>
    <version>0.0.1</version>
</dependency>

In your code:

import ca.pjer.glbctl.GlbCtl;
import ca.pjer.glbctl.GlbCtlFactory;
import ca.pjer.glbctl.GlbNode;

import java.io.IOException;

public class Main {

    public static void main(String[] args) {

        // try-with-resources to open and finally close the connection
        try (GlbCtl ctl = GlbCtlFactory.connect("127.0.0.1", 4444)) {

            // add or update node (weight of -1 to remove, 0 to drain)
            ctl.update(new GlbNode("10.0.0.1", 8080), 5);

            // query node
            ctl.getInfo().getRouter().entrySet().forEach(entry ->
                    System.out.println(entry.getKey().getHost() + ":" + entry.getKey().getPort()
                            + " has a weight of " + entry.getValue().getWeight()
                            + " and " + entry.getValue().getConns() + " active connections"));

            // query stats
            System.out.println("Stats: " + ctl.getStat());


        } catch (InterruptedException e) {
            // ignore
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Versions

Version
0.0.1