Java Code Examples for io.atomix.protocols.raft.RaftServer#Role

The following examples show how to use io.atomix.protocols.raft.RaftServer#Role . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RaftContext.java    From atomix with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an internal state for the given state type.
 */
private RaftRole createRole(RaftServer.Role role) {
  switch (role) {
    case INACTIVE:
      return new InactiveRole(this);
    case PASSIVE:
      return new PassiveRole(this);
    case PROMOTABLE:
      return new PromotableRole(this);
    case FOLLOWER:
      return new FollowerRole(this);
    case CANDIDATE:
      return new CandidateRole(this);
    case LEADER:
      return new LeaderRole(this);
    default:
      throw new AssertionError();
  }
}
 
Example 2
Source File: PromotableRole.java    From atomix with Apache License 2.0 4 votes vote down vote up
@Override
public RaftServer.Role role() {
  return RaftServer.Role.PROMOTABLE;
}
 
Example 3
Source File: PassiveRole.java    From atomix with Apache License 2.0 4 votes vote down vote up
@Override
public RaftServer.Role role() {
  return RaftServer.Role.PASSIVE;
}
 
Example 4
Source File: CandidateRole.java    From atomix with Apache License 2.0 4 votes vote down vote up
@Override
public RaftServer.Role role() {
  return RaftServer.Role.CANDIDATE;
}
 
Example 5
Source File: LeaderRole.java    From atomix with Apache License 2.0 4 votes vote down vote up
@Override
public RaftServer.Role role() {
  return RaftServer.Role.LEADER;
}
 
Example 6
Source File: InactiveRole.java    From atomix with Apache License 2.0 4 votes vote down vote up
@Override
public RaftServer.Role role() {
  return RaftServer.Role.INACTIVE;
}
 
Example 7
Source File: FollowerRole.java    From atomix with Apache License 2.0 4 votes vote down vote up
@Override
public RaftServer.Role role() {
  return RaftServer.Role.FOLLOWER;
}
 
Example 8
Source File: RaftContext.java    From atomix with Apache License 2.0 2 votes vote down vote up
/**
 * Adds a role change listener.
 *
 * @param listener The role change listener.
 */
public void addRoleChangeListener(Consumer<RaftServer.Role> listener) {
  roleChangeListeners.add(listener);
}
 
Example 9
Source File: RaftContext.java    From atomix with Apache License 2.0 2 votes vote down vote up
/**
 * Removes a role change listener.
 *
 * @param listener The role change listener.
 */
public void removeRoleChangeListener(Consumer<RaftServer.Role> listener) {
  roleChangeListeners.remove(listener);
}
 
Example 10
Source File: RaftContext.java    From atomix with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the current server role.
 *
 * @return The current server role.
 */
public RaftServer.Role getRole() {
  return role.role();
}
 
Example 11
Source File: RaftRole.java    From atomix with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the server state type.
 *
 * @return The server state type.
 */
RaftServer.Role role();
 
Example 12
Source File: AbstractRole.java    From atomix with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the Raft state represented by this state.
 *
 * @return The Raft state represented by this state.
 */
public abstract RaftServer.Role role();