Dropwizard Atomix Bundle

Atomix support in Dropwizard

License

License

Categories

Categories

DropWizard Container Microservices Atomix Application Layer Libs Distributed Applications
GroupId

GroupId

com.smoketurner.dropwizard
ArtifactId

ArtifactId

atomix-core
Last Version

Last Version

1.3.7-1
Release Date

Release Date

Type

Type

jar
Description

Description

Dropwizard Atomix Bundle
Atomix support in Dropwizard

Download atomix-core

How to add to project

<!-- https://jarcasting.com/artifacts/com.smoketurner.dropwizard/atomix-core/ -->
<dependency>
    <groupId>com.smoketurner.dropwizard</groupId>
    <artifactId>atomix-core</artifactId>
    <version>1.3.7-1</version>
</dependency>
// https://jarcasting.com/artifacts/com.smoketurner.dropwizard/atomix-core/
implementation 'com.smoketurner.dropwizard:atomix-core:1.3.7-1'
// https://jarcasting.com/artifacts/com.smoketurner.dropwizard/atomix-core/
implementation ("com.smoketurner.dropwizard:atomix-core:1.3.7-1")
'com.smoketurner.dropwizard:atomix-core:jar:1.3.7-1'
<dependency org="com.smoketurner.dropwizard" name="atomix-core" rev="1.3.7-1">
  <artifact name="atomix-core" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.smoketurner.dropwizard', module='atomix-core', version='1.3.7-1')
)
libraryDependencies += "com.smoketurner.dropwizard" % "atomix-core" % "1.3.7-1"
[com.smoketurner.dropwizard/atomix-core "1.3.7-1"]

Dependencies

compile (5)

Group / Artifact Type Version
io.dropwizard : dropwizard-core jar
io.atomix : atomix jar 3.0.6
io.atomix : atomix-raft jar 3.0.6
io.atomix : atomix-primary-backup jar 3.0.6
io.atomix : atomix-gossip jar 3.0.6

test (4)

Group / Artifact Type Version
io.dropwizard : dropwizard-testing jar
org.mockito : mockito-core jar 2.23.0
org.openjdk.jmh : jmh-core jar 1.21
org.openjdk.jmh : jmh-generator-annprocess jar 1.21

Project Modules

There are no modules declared in this project.

Dropwizard Atomix

Build Status Maven Central GitHub license Become a Patron

A bundle for integrating Atomix in Dropwizard applications.

Usage

Within your Configuration class, add the following:

@Valid
@NotNull
private final AtomixFactory atomix = new AtomixFactory();

@JsonProperty
public AtomixFactory getAtomixFactory() {
    return atomix;
}

Then with your Application class, you can access an Atomix by doing the following:

@Override
public void initialize(Bootstrap<MyConfiguration> bootstrap) {
    bootstrap.addBundle(new AtomixBundle<MyConfiguration>() {
        @Override
        public AtomixFactory getAtomixFactory(MyConfiguration configuration) {
            return configuration.getAtomixFactory();
        }
    });
}

@Override
public void run(MyConfiguration configuration, Environment environment) throws Exception {
    Atomix atomix = configuration.getAtomixFactory().build();
}

Maven Artifacts

This project is available on Maven Central. To add it to your project simply add the following dependencies to your pom.xml:

<dependency>
    <groupId>com.smoketurner.dropwizard</groupId>
    <artifactId>atomix-core</artifactId>
    <version>1.3.7-1</version>
</dependency>

Example Application

To try the example application, checkout the code from Github then build the example hello world application.

git clone https://github.com/smoketurner/dropwizard-atomix.git
cd dropwizard-atomix
./mvnw compile package
cd atomix-example

You then need to open 3 separate terminal windows to launch 3 instances of the application:

java -jar target/atomix-example-1.3.7-2-SNAPSHOT.jar server config1.yml
java -jar target/atomix-example-1.3.7-2-SNAPSHOT.jar server config2.yml
java -jar target/atomix-example-1.3.7-2-SNAPSHOT.jar server config3.yml

Once a quorum has been reached, Jetty will start up as normal on a random port which you'll be able to see in the logs.

INFO  [2018-01-07 15:29:43,489] org.eclipse.jetty.server.handler.ContextHandler: Started i.d.j.MutableServletContextHandler@2ad99cf3{/admin,null,AVAILABLE}
INFO  [2018-01-07 15:29:43,494] org.eclipse.jetty.server.AbstractConnector: Started hello-world@554f0dfb{HTTP/1.1,[http/1.1]}{0.0.0.0:55419}
INFO  [2018-01-07 15:29:43,494] org.eclipse.jetty.server.Server: Started @13775ms

You can then visit http://localhost:55419/hello-world to see the Dropwizard Getting Started example, but using a distributed counter across the cluster.

Support

Please file bug reports and feature requests in GitHub issues.

License

Copyright (c) 2018 Smoke Turner, LLC

This library is licensed under the Apache License, Version 2.0.

See http://www.apache.org/licenses/LICENSE-2.0.html or the LICENSE file in this repository for the full license text.

com.smoketurner.dropwizard

Smoke Turner, LLC

Versions

Version
1.3.7-1
1.3.5-2
1.3.5-1
1.3.0-1
1.2.3-2
1.2.3-1