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

com.arangodb.shaded.vertx.core.spi.cluster.NodeSelector Maven / Gradle / Ivy

There is a newer version: 7.8.0
Show newest version
/*
 * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
 * which is available at https://www.apache.org/licenses/LICENSE-2.0.
 *
 * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
 */

package com.arangodb.shaded.vertx.core.spi.cluster;

import com.arangodb.shaded.vertx.core.Promise;
import com.arangodb.shaded.vertx.core.Vertx;
import com.arangodb.shaded.vertx.core.eventbus.Message;
import com.arangodb.shaded.vertx.core.impl.VertxBuilder;
import com.arangodb.shaded.vertx.core.spi.VertxServiceProvider;

/**
 * Used by the {@link com.arangodb.shaded.vertx.core.eventbus.EventBus clustered EventBus} to select a node for a given message.
 * 

* This selector is skipped only when the user raises the {@link com.arangodb.shaded.vertx.core.eventbus.DeliveryOptions#setLocalOnly(boolean)} flag. * Consequently, implementations must be aware of local {@link com.arangodb.shaded.vertx.core.eventbus.EventBus} registrations. */ public interface NodeSelector extends VertxServiceProvider { @Override default void init(VertxBuilder builder) { if (builder.clusterNodeSelector() == null) { builder.clusterNodeSelector(this); } } /** * Invoked before the {@code vertx} instance tries to join the cluster. */ void init(Vertx vertx, ClusterManager clusterManager); /** * Invoked after the clustered {@link com.arangodb.shaded.vertx.core.eventbus.EventBus} has started. */ void eventBusStarted(); /** * Select a node for sending the given {@code message}. * *

The provided {@code promise} needs to be completed with {@link Promise#tryComplete} and {@link Promise#tryFail} * as it might completed outside the selector. * * @throws IllegalArgumentException if {@link Message#isSend()} returns {@code false} */ void selectForSend(Message message, Promise promise); /** * Select a node for publishing the given {@code message}. * *

The provided {@code promise} needs to be completed with {@link Promise#tryComplete} and {@link Promise#tryFail} * as it might completed outside the selector. * * @throws IllegalArgumentException if {@link Message#isSend()} returns {@code true} */ void selectForPublish(Message message, Promise> promise); /** * Invoked by the {@link ClusterManager} when messaging handler registrations are added or removed. */ void registrationsUpdated(RegistrationUpdateEvent event); /** * Invoked by the {@link ClusterManager} when some handler registrations have been lost. */ void registrationsLost(); /** * Invoked by the {@link ClusterManager} to determine if the node selector wants updates for the given {@code address}. * * @param address the event bus address * @return {@code true} if the node selector wants updates for the given {@code address}, {@code false} otherwise */ default boolean wantsUpdatesFor(String address) { return true; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy