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

org.infinispan.remoting.transport.jgroups.ClusterView Maven / Gradle / Ivy

There is a newer version: 9.1.7.Final
Show newest version
package org.infinispan.remoting.transport.jgroups;

import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.infinispan.commons.util.Immutables;
import org.infinispan.remoting.transport.Address;

/**
 * Information about the JGroups cluster.
 *
 * @author Dan Berindei
 * @since 9.1
 */
public class ClusterView {
   static final int INITIAL_VIEW_ID = -1;
   static final int FINAL_VIEW_ID = Integer.MAX_VALUE;

   private final int viewId;
   private final List
members; private final Set
membersSet; private final Address coordinator; private final boolean isCoordinator; ClusterView(int viewId, List
members, Address self) { this.viewId = viewId; this.members = Immutables.immutableListCopy(members); this.membersSet = Collections.unmodifiableSet(new HashSet<>(members)); if (!members.isEmpty()) { this.coordinator = members.get(0); this.isCoordinator = coordinator.equals(self); } else { this.coordinator = null; this.isCoordinator = false; } } public int getViewId() { return viewId; } public boolean isViewIdAtLeast(int expectedViewId) { return expectedViewId <= viewId; } public boolean isStopped() { return viewId == FINAL_VIEW_ID; } public List
getMembers() { return members; } public Set
getMembersSet() { return membersSet; } public Address getCoordinator() { return coordinator; } public boolean isCoordinator() { return isCoordinator; } @Override public String toString() { return coordinator + "|" + viewId + members; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy