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

net.sf.hajdbc.state.health.NodeHealth Maven / Gradle / Ivy

There is a newer version: 3.6.61
Show newest version
package net.sf.hajdbc.state.health;

import java.io.Serializable;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;

import net.sf.hajdbc.state.distributed.NodeState;

public class NodeHealth implements Serializable {
  private static final long serialVersionUID = 1L;

  private NodeState state = NodeState.offline;
  private final Set activeDBs = new CopyOnWriteArraySet<>();
  private volatile long local;
  private volatile long arbiter;
  private volatile boolean lastOnlyHost = false;

  public Set getActiveDBs() {
    return activeDBs;
  }

  public NodeState getState() {
    return state;
  }

  public void setState(NodeState state) {
    this.state = state;
  }

  public boolean isValidArbiter() {
    return arbiter>0;
  }

  public boolean isValidLocal() {
    return isValidArbiter()&&(local>=arbiter);
  }

  public boolean isEmpty() {
    return local==0&&arbiter==0;
  }

  public long getLocal() {
    return local;
  }

  public void setLocal(long local) {
    this.local = local;
  }

  public long getArbiter() {
    return arbiter;
  }

  public void setArbiter(long arbiter) {
    this.arbiter = arbiter;
  }

  public boolean isLastOnlyHost() {
    return lastOnlyHost;
  }

  public void setLastOnlyHost(boolean lastOnlyHost) {
    this.lastOnlyHost = lastOnlyHost;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy