Selector

Introduction

What is the Selector? As its name suggests, it allows users to select specific items from a given namespace and context. There is a related trait, also named Selector, whose definition can be found below.

There is a specific scenario in Metasrv service. When a request to create a table is sent to the Metasrv service, it creates a routing table (the details of table creation will not be described here). The Metasrv service needs to select the appropriate Datanode list when creating a routing table.

Selector Type

Currently, there are two types of Selector available in the Metasrv service: LeasebasedSelector and LoadBasedSelector.

LeasebasedSelector is just a simple implementation of Selector, but it is not recommended.

It shuffles available Datanodes, and returns the list.

LoadBasedSelector

LoadBasedSelector is another implementation of the Selector.

It sorts available Datanodes according to the load, and returns a sorted list of these Datanodes.

Configuration

You can configure the Selector when starting the Metasrv service, with the default being LoadBasedSelector.

For example:

  1. cargo run -- metasrv start --selector load_based
  1. cargo run -- metasrv start --selector lease_based