Megamind - TheBloom46/bloommanager-wiki GitHub Wiki
Are you developing a plugin for a multiple-node environment in which you need tasks to only be run by one node? BloomManager automatically assigns the node with the longest runtime as the "master" node. Megamind is a Developer API feature that allows developers to execute a runnable or repeatedly execute a runnable only on the node if it's the master.
Potential Use Case
In a multiple-node environment, you might need a queue plugin. Using Megamind, you can schedule a runnable that checks if any active queue can be incremented. In such a scenario, register a repeating runnable to check queues with Megamind on every node. If the node is the master, it will begin the task upon registration, otherwise, the node will routinely check if it becomes master. Once the non-master node becomes master, it will begin the queue incrementation runnable.
Usage
You can access the API by compiling this repository (bloommanager-wiki) in your build software. Copius JavaDocs are included.
BungeeCord and Gradle Example
Gradle
build.gradle:
repositories {
maven { url 'https://jitpack.io/' }
}
dependencies {
compileOnly 'com.github.TheBloom46:bloommanager-wiki:v1.4'
}
Main
Megamind megamind = ((BloomManager) this.getProxy().getPluginManager().getPlugin("BloomManager")).getMegamind();
//The below logic registers a task to print "potato" in the console only if the proxy is master
megamindBungee.registerTask("potato printer", new Runnable() {
@Override
public void run() {
getLogger().log(Level.SEVERE, "potato");
}
}, this);