In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
In this article, the editor introduces in detail the "Elasticsearch metadata how to build metadata and routing classes", the content is detailed, the steps are clear, and the details are handled properly. I hope this "Elasticsearch metadata how to build metadata and routing classes" article can help you solve your doubts.
Metadata part
Although the code is divided into distributed and data parts at the beginning of the source overview, the boundaries are not clear. The previous articles can be said to be the convergence of these two parts. We are fast approaching the data (index) section. This article analyzes the problems left over from the previous analysis of cluster: Metadata and routing, although the code of these two parts is in cluster, it is directly related to index.
The metadata part is mainly about the construction and manipulation of metadata related to indexes.
The metadata part mainly includes
Alias metadata (AliasMetaData): index alias related, mapping the index to the related route by alias
Index metadata (IndexMetaData): index-related, such as number of shard, number of replica, creation time, etc.
Index template metadata (IndexTemplateMetaData): template related, such as preset mapping, aliases, etc.
Mapping metadata (MappingMetadata): mapping-related metadata, such as id,routing
And RestoreMetadata and SnapshortMetadata and so on. These metadata include all the metadata related to the index, which is at the cluster level, which I personally think is why this part is put into cluster.
Metadata is the configuration information at the cluster level of related functions. Most of them are similar to the logic of the data class itself and are not complex. They are composed of field and some set and get methods to field, but some of its field are classes themselves. And some metadata classes provide more complex data manipulation methods, such as MappingMetadata will have build and some data format analysis methods. Here is a brief analysis of two to explain.
The following is a partial fields of IndexMetadata:
You can see that there are some index-related metadata, many of which must be removed in use. Such as Mapping, etc. The methods are mostly get and set, and there is not much complicated logic. Filed, which is different from IndexMetadata,MappingMetaData, is mostly classified internally, as shown in the following figure:
The id,routing and timestamp fields here are inner classes because they contain other logic and cannot be implemented through basic data types. The key part of the content field mapping in Mapping is a compressed string (source), which is a string in json format. So MappingMetadata contains a lot of more complex methods for parsing source.
Other metadata classes will not be explained one by one with two very similar ones. If you are interested, please refer to the relevant source code. Finally, let's take a look at the service related to MetaData. These service provide interfaces for reading and manipulating related MetaData. Take MappingMetaDataService as an example to give a simple illustration. Its class diagram is as follows:
MappingMetaDataService provides MappingMetaData update, removal and other related operations. These methods involve the operation of the index, which will not be expanded here, but will be involved in the later analysis of the index.
The above related analysis of metadata, this part itself does not involve too complex logic, complex logic is in service, but because the method of service will involve the operation of Index, so here is a simple analysis, and then explain the relevant methods in detail in the later index correlation analysis.
Like MetaData, this part of routing is mainly metadata related to indexed routes in the cluster, but unlike MetaData, this part has a hierarchical structure. ShardRouting is the most basic element, which makes up the index
IndexRoutingTable, and finally the RoutingTable of the cluster is composed of IndexRoutingTable.
ShardRouting, inheritance relationship
As shown in the following figure:
A Routing is essentially a serializable XContent,ImmutableShardRount that is immutable in Routing and their set and get methods such as id, version, etc. MutableShardRouting is mainly related to shard operations, such as reassignment, primaryshard changes and so on. A primary of a shard and all the replica form a shardRoutingTable, and part of its code is as follows:
Public class IndexShardRoutingTable implements Iterable {final ShardShuffler shuffler; final ShardId shardId; final ShardRouting primary; final ImmutableList primaryAsList; final ImmutableList replicas; final ImmutableList shards; final ImmutableList activeShards; final ImmutableList assignedShards;.}
A replica of all states of the shard is recorded in the ShardRoutingTable. Index consists of multiple shard, so IndexRoutingTable is made up of ShardRoutingTable, the code is as follows:
Public class IndexRoutingTable implements Iterable {private final String index; private final ShardShuffler shuffler; / / note, we assume that when the index routing is created, ShardRoutings are created for all possible number of / / shards with state set to UNASSIGNED private final ImmutableOpenIntMap shards; private final ImmutableList allShards; private final ImmutableList allActiveShards;.}
Finally, all the IndexRoutingTable form the RoutingTable of the cluster:
Public class RoutingTable implements Iterable {public static final RoutingTable EMPTY_ROUTING_TABLE = builder () .build (); private final long version; / / index to IndexRoutingTable map private final ImmutableMap indicesRouting;.}
This is the indexRoutingTable line, and there is another RoutingTable, which is nodeRoutingTable, which records the routing information of the shard on each node. The shardRouting forms the nodeRoutingTable, while the NodeRoutingTable forms the NodesRoutingTable (Cluster shardRouting).
Like all other modules, the related operations of these Routing are also provided by service, and this part also has the following related classes of shard operations, such as ShardIterator,ShardShuffle and so on.
Read here, this "Elasticsearch metadata how to build metadata and routing classes" article has been introduced, want to master the knowledge of this article also need to practice and use in order to understand, if you want to know more about the article, welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.