Skip to content
This repository has been archived by the owner on Jul 27, 2021. It is now read-only.

A simple round-robin selector for a hazelcast cluster. Useful for load-balancing without an authoritative node.

Notifications You must be signed in to change notification settings

realjenius/hazelcast-roundrobin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Hazelcast Round-Robin Selector

This is a basic component for doing non-authoritative round-robining between Hazelcast cluster instances. This can be useful both as a producer and a consumer for handling balancing of work in a "nearly fair" model.

For a consumer, basic usage looks like this:

HazelcastInstance instance = // ...
RoundRobinSelector selector = new RoundRobinSelector(instance, "selector-name");
Member member = selector.select();
if(member.equals(instance.getCluster().getLocalMember()) {
 // ...
}

This is most useful if your application advances the selector by some different production (such as a job being added to a worker queue).

To advance the selector, you simply do this:

selector.advance();

It's often useful when you wish to "push" the work to a particular member that you do something like this:

Something something = produceSomething();
Member member = selector.advance().select();
String uuid = member.getUuid();
ITopic<Something> topic = instance.getTopic("worker-channel-" + uuid);
topic.publish(something);

About

A simple round-robin selector for a hazelcast cluster. Useful for load-balancing without an authoritative node.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages