In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
ES, there is a class of parameters can be dynamically adjusted, such as the number of copies: number_of_replicas.
How do I add my own custom parameters in plug-in development?
In the plug-in entry, add onModule(ClusterModule).
public class ShgyPlugin extends Plugin { @Override public String name() { return "shgy-plugin"; } @Override public String description() { return "shgy plugin "; } public void onModule(ClusterModule module){ module.registerIndexDynamicSetting("index.custom_setting", new Validator() { @Override public String validate(String setting, String value, ClusterState clusterState) { if (value == null) { throw new NullPointerException("value must not be null"); } return null; } }); }}
Compile the code, install the plug-in, and test it with the following script:
curl -X PUT "localhost:9200/twitter/_settings" -H 'Content-Type: application/json' -d'{ "index" : { "custom_setting" : 2 }}'curl -XGET 'http://localhost:9200/twitter/_settings? pretty'
Parameters are used in code, usually in TransportAction, and the code snippet is as follows:
ClusterState clusterState = clusterService.state(); clusterState.blocks().globalBlockedRaiseException(ClusterBlockLevel.READ); String concreteSingleIndex = indexNameExpressionResolver.concreteSingleIndex(clusterState, request); IndexMetaData indexMeta = clusterState.getMetaData().index(concreteSingleIndex); int sectionCnt = indexMeta.getSettings().getAsInt("index.custom_settings",-1);
That is, get clusterState through clusterService, then get IndexMetaData, and then get Settings.
Custom dynamic parameters, with the use of templates, do not need to manually create indexes frequently. This knowledge point should be summarized as part of ES plug-in development.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.