Skip to content
maobaolong edited this page Oct 13, 2021 · 2 revisions

Ratis shell principle and scenario

Background

The High-Availble implementation of both the master, job master of Alluxio and Ozone Manager, StorageContainerManager of Ozone are based on apache ratis. And these service are all need ratis related shell to get or control ratis group, something likes elect leader, get peer information, add or remove peers, set priority and some other feature. But the two famous opensouce community Ozone and Alluxio are implementing these kinds of features individually, the logic and details of implementation from each side are similar. Obviously, we shouldn't do something repeat. So, both alluxio and ozone just need to dependent a common third-party implements of ratis shell if we do some abstraction and put the public logic into an individual dependency.

Structure

As the figure above, after we abstract a ratis-shell project, both alluxio and Ozone just need integrate ratis-shell as a shell tools to ratis server, more than this, other services which use ratis server can use ratis shell also.

Feature supported

  • Elect Leader
  • Get peer information, leader information, commit index
  • Set priority
  • Add peer
  • Remove peer

Build & How to use

Build

A fat-jar will be generated after execute the following command mvn clean package

Configuration

  • conf/ratis-shell-site.properties The following configuration, shows the groupid and peers configure example of alluxio-master, alluxio-jobmaster, ozone-om, ozone-scm.
ratis.shell.alluxio-master.groupid=02511d47-d67c-49a3-9011-abb3109a44c1
ratis.shell.alluxio-master.peers=localhost:19200,localhost:19201,localhost:19202
ratis.shell.alluxio-jobmaster.groupid=02511d47-d67c-49a3-9011-abb3109a44c1
ratis.shell.alluxio-jobmaster.peers=localhost:19200,localhost:19201,localhost:19202
ratis.shell.ozone-om.groupid=02511d47-d67c-49a3-9011-abb3109a44c1
ratis.shell.ozone-om.peers=localhost:19200,localhost:19201,localhost:19202
ratis.shell.ozone-scm.groupid=02511d47-d67c-49a3-9011-abb3109a44c1
ratis.shell.ozone-scm.peers=localhost:19200,localhost:19201,localhost:19202

In fact, you don't have to specific or privode the groupid if the ratis server is belongs to only one group. Shell command line

  • Get ratis peer information (specific serviceid)
# Get ratis peer information (specific serviceid)
bin/ratis sh info -serviceid alluxio-master

# Get ratis peer information (specific peers only)
bin/ratis sh info -peers localhost:19200,localhost:19201,localhost:19202
[server {
  id: "localhost_19200"
  address: "localhost:19200"
  priority: 1
}
commitIndex: 18
, server {
  id: "localhost_19202"
  address: "localhost:19202"
  priority: 1
}
commitIndex: 18
, server {
  id: "localhost_19201"
  address: "localhost:19201"
  priority: 2
}
commitIndex: 18
]
leader id: localhost_19201
  • Trigger elect leader to a specific peer
# Trigger elect leader to a specific peer
bin/ratis sh elect -peers localhost:19200,localhost:19201,localhost:19202 -address localhost:19201 -groupid 02511d47-d67c-49a3-9011-abb3109a44c1
Applying new peer state before transferring leadership: [localhost_19202|rpc:localhost:19202|priority:1, localhost_19201|rpc:localhost:19201|priority:2, localhost_19200|rpc:localhost:19200|priority:1]
Transferring leadership to server with address <localhost:19201> and with RaftPeerId <localhost_19201>
Transferring leadership initiated

Conclusion

ratis-shell is a software which producted from abstract the common part of multi software, thus can reduce the duplicate code. In the process of participating in a project, we should actually jump out of the specific project and think more about the software architecture in the whole ecology.

References