All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jgroups.protocols.relay.RandomSiteMasterPicker Maven / Gradle / Ivy

Go to download

This artifact provides a single jar that contains all classes required to use remote Jakarta Enterprise Beans and Jakarta Messaging, including all dependencies. It is intended for use by those not using maven, maven users should just import the Jakarta Enterprise Beans and Jakarta Messaging BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up with different versions on classes on the class path).

The newest version!
package org.jgroups.protocols.relay;

import org.jgroups.Address;
import org.jgroups.util.Util;

import java.util.List;
import java.util.function.Supplier;

/**
 * Implementation of {@link SiteMasterPicker} which picks random site masters / routes to site masters
 * @author Bela Ban
 * @since  5.3.1
 */
public class RandomSiteMasterPicker implements SiteMasterPicker {
    protected boolean           verbose;
    protected Supplier
addr_supplier; public RandomSiteMasterPicker() { } public boolean verbose() {return verbose;} public SiteMasterPicker verbose(boolean b) {verbose=b; return this;} public SiteMasterPicker addressSupplier(Supplier
s) {addr_supplier=s; return this;} public Address pickSiteMaster(List
site_masters, Address original_sender) { Address sm_addr=Util.pickRandomElement(site_masters); if(verbose) System.out.printf("-- picked local site master %s to forward message to\n", sm_addr); return sm_addr; } public Route pickRoute(String site, List routes, Address original_sender) { Route route=Util.pickRandomElement(routes); if(verbose) System.out.printf("-- %s picked remote site master %s and bridge %s to route message\n", addr_supplier != null? addr_supplier.get() + ":" : "", route.siteMaster(), route.bridge().address()); return route; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy