In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how to achieve zero invasion of the program based on javaagent zkconfigutil, the article is very detailed, has a certain reference value, interested friends must read it!
First-come effect:
A Demo in my project is the configuration item of the whole project, as follows:
@ TypeZkConfigurablepublic final class Demo {@ FieldZkConfigurable (dynamicUpdate = true) public static String F1 = "F1"; @ FieldZkConfigurable (dynamicUpdate = true) public static String F2 = "F2"; @ FieldZkConfigurable (dynamicUpdate = true) public static Boolean F3 = false; @ FieldZkConfigurable public static Boolean F4 = true;}
The configuration item F1 field dynamicUpdate = true means that this field needs to be dynamically updated, that is, F1 needs to be modified after the value on zookeeper changes. The F4 field uses the default dynamicUpdate false, that is, there is no need for dynamic updates.
How to use Demo:
Public static void main (String [] args) throws InterruptedException {while (true) {System.out.println ("Demo.F1 =" + Demo.F1); loop ();}} public static void loop () throws InterruptedException {Thread.sleep (2000L);}
There is no need to explain this code, print F1 once in 2s (this field is dynamically updated! )
The ok code has been written, is there no intrusion into your code at all?
Look at startup:
-javaagent:/home/jerry/ZKCUAgent.jar=zk@10.31.44.38:2181#class@com.jerry.zkconfigutil.Demo
Javaagent is mainly used here. Add the above parameters to the jvm parameter. First,-javaagent specifies the jar of our agent, here in my home directory, and then the = sign is used to specify the agentOps of agent, that is, the parameter, in the format of zk@z1,z2#class@c1,c2,c3.
Ok, start it directly with the javaagent parameter, and now our Demo has been configured as zookeeper.
Enjoy it!
The launcher runs as follows:
Modify the value of F1 field on zookeeper to F321, and run as follows:
How, the use of stand-up is not very easy, and practical, through the jvm javaagent parameter control, zero intrusion to the service. It's a perfect combination with zookeeper's eclipse plug-in! This is the first official version released by my brother, and there is complete code and test Demo on osc's git repository and github.
The above is all the content of this article "how to achieve zero invasion of zkconfigutil programs based on javaagent". Thank you for reading! Hope to share the content to help you, more related knowledge, 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
< # / /-/ / Copyright (c) {charbel
© 2024 shulou.com SLNews company. All rights reserved.