In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what are the knowledge points of apollo". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. Summary:
1. Management: application management, namespace management, department management, user management, role management, rights management, audit management
two。 Data structure: application, element item, element change record, element release record, element grayscale rules (temporary namespace)
1. Use: configure server address, configure local cache address, configure environment evn, configure cluster, configure appid
two。 Use configuration methods: java environment, system management, configuration files,-D parameters
Second, the application of three axes
(1) configuration Center deployment
1. Import two database scripts into the mysql database
two。 Modify database connection and remote service invocation address configuration in configService, adminService, and portal projects
3. Start three projects: configService, adminService and portal
(2) examples of program application
1.pom file
Com.ctrip.framework.apollo apollo-client 1.4.0 com.ctrip.framework.apollo apollo-core 1.4.0
2.app.properties (under the resources/META-INF directory)
# testapp.id=umemberenv=DEVapollo.meta= http://localhost:8080
3. Test code
Package com.unilife.test;import java.io.BufferedReader;import java.io.InputStreamReader;import com.ctrip.framework.apollo.Config;import com.ctrip.framework.apollo.ConfigChangeListener;import com.ctrip.framework.apollo.ConfigService;import com.ctrip.framework.apollo.model.ConfigChange;import com.ctrip.framework.apollo.model.ConfigChangeEvent;import com.google.common.base.Charsets Public class TestApollo {public static void main (String [] args) throws Exception {Config appConfig=ConfigService.getAppConfig (); try {String k1=appConfig.getProperty ("jdbc.type", null); / / K1 = v11 String k2=appConfig.getProperty ("K2", null) / / K2 = v21 System.out.println (K1); System.out.println (K2);} catch (Exception e) {/ / TODO Auto-generated catch block e.printStackTrace () } appConfig.addChangeListener (new ConfigChangeListener () {public void onChange (ConfigChangeEvent changeEvent) {/ / do something System.out.println ("Changes for namespace:" + changeEvent.getNamespace ()) For (String key: changeEvent.changedKeys ()) {ConfigChange change = changeEvent.getChange (key); System.out.println ("Change-key:" + change.getPropertyName () + ", oldValue:" + change.getOldValue () + ", newValue:" + change.getNewValue () + ", changeType:" + change.getChangeType () }); while (true) {System.out.print (">"); String input = new BufferedReader (new InputStreamReader (System.in, Charsets.UTF_8). ReadLine () If (input = = null | | input.length () = = 0) {continue;} input = input.trim (); if (input.equalsIgnoreCase ("quit")) {System.exit (0) } String temp=appConfig.getProperty (input,null); System.out.println (temp);}
III. Theory (turn)
1. Comparison between SpringCloudConfig and Apollo.
2. Introduction of apollo
3. Apollo architecture design principle.
4. The principle of client pulling configuration through apollo
1. Comparison between SpringCloudConfig and Apollo.
As shown in the above picture
SpringCloudConfig has the advantage of native support for SpringBoot and is a SpringCloud component. The disadvantage is that there is no interface management, and it needs git,SpringCloudBus and Mq to support its dynamic update.
The advantage of Apollo is that the technology stack is single, and only Mysql is needed to support dynamic update configuration, which is easy to maintain. The disadvantage is not the SpringCloud system, although open source, version updates are also active, but the support for SpringCloud is not as good as SpringCloudConfig.
2. Introduction of apollo
Apollo (Apollo) is an open source configuration management center developed by Ctrip Framework Department, which can centrally manage the configuration of different environments and clusters, and can be pushed to the application side in real time after configuration modification, and has standardized permissions, process governance and other characteristics.
Apollo supports 4 dimensions to manage the configuration in Key-Value format:
Application (application)
Environment (environment)
Cluster (Cluster)
Namespace (Namespace)
At the same time, Apollo is based on open source mode development, open source address
3. Apollo architecture design principle.
The figure above briefly describes the overall design of Apollo, which we can look at from the bottom up:
Config Service provides configured read, push and other functions, and the service object is the Apollo client
Admin Service provides functions such as configuration modification and release, and the service object is Apollo Portal (management interface).
Both Config Service and Admin Service are multi-instance, stateless deployments, so you need to register yourself with Eureka and keep your heart beating on top of Eureka. We have built a layer of Meta Server service discovery interface that encapsulates Eureka.
Client obtains the list of ConfigService services (IP+Port) through the domain name access Meta Server, and then accesses the service directly through IP+Port. At the same time, in the
Client side will do load balance, error retry
Portal obtains the list of AdminService services (IP+Port) through the domain name access Meta Server, and then accesses the service directly through IP+Port. At the same time, in the
Portal side will do load balance, error retry
To simplify deployment, we will actually deploy the three logical roles Config Service, Eureka and Meta Server in the same JVM process
4. The principle of client pulling configuration through apollo
The figure above briefly describes the implementation principle of the Apollo client:
The client and the server maintain a long connection so that they can get the push of the configuration update the first time.
The client also periodically pulls the latest configuration of the application from the Apollo configuration center server.
This is a fallback mechanism to prevent the configuration from being updated due to the failure of the push mechanism
Regular pull by the client will report the local version, so in general, the server will return 304-Not Modified for the scheduled pull operation.
The timing frequency defaults to pulling every 5 minutes, and the client can also override it by specifying System Property: apollo.refreshInterval at run time, in minutes.
After the client obtains the latest configuration of the application from the Apollo configuration center server, it will save it in memory.
The client will cache a copy of the configuration obtained from the server on the local file system
The configuration can still be restored locally when the service is not available or the network is not available.
The application gets the latest configuration and subscription configuration update notification from the Apollo client
Configure update push implementation
As mentioned earlier, the Apollo client and server maintain a long connection so that they can get a push of configuration updates as soon as possible.
Persistent connections are actually achieved through Http Long Polling, specifically:
The client initiates a Http request to the server
The server will keep the connection for 60 seconds.
If there is a configuration change concerned by the client within 60 seconds, the held client request will immediately return and inform the client of the namespace information of the configuration change, and the client will pull the latest configuration of the corresponding namespace accordingly.
If there is no configuration change concerned by the client within 60 seconds, the Http status code 304 will be returned to the client.
The client will re-initiate the connection immediately after receiving the server request, returning to the first step
Considering that tens of thousands of clients will initiate long connections to the server, we use async servlet (Spring DeferredResult) to serve Http Long Polling requests on the server.
This is the end of the content of "what are the knowledge points of apollo". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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: 291
*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.