Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Hadoop 2.4What is the principle of namenode ha

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "what is the principle of hadoop 2.4 namenode ha". In the operation of practical cases, many people will encounter such a dilemma, so 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!

In the HA section of 2.0, we can see that there are more DFSZKFailoverController and JournalNode processes than the original 1.0.

As the name implies, DFSZKFailoverController is the controller used for the whole active / standby handover.

JournalNode is the transmission medium shared by active and standby metadata.

While DFSZKFailoverController is mainly responsible for the election of active NN through ActiveStandbyElector, and the monitoring of nn itself is realized through the HealthMonitor class, let's analyze what work HealthMonitor has done and the process of monitoring and calling NN.

For the state of NN, the following categories are defined:

Public enum State {/ * * The health monitor is still starting up. * / INITIALIZING, / * * The service is not responding to health check RPCs. * / SERVICE_NOT_RESPONDING, / * * The service is connected and healthy. * / SERVICE_HEALTHY, / * * The service is running but unhealthy. * / SERVICE_UNHEALTHY, / * * The health monitor itself failed unrecoverably and can * no longer provide accurate information. * / HEALTH_MONITOR_FAILED;}

You can see that there are two types of states defined, ok or failed.

For the monitoring results, healthMonitor is realized by setting a callback function.

Public void addCallback (Callback cb) {this.callbacks.add (cb);} public synchronized void addServiceStateCallback (ServiceStateCallback cb) {this.serviceStateCallbacks.add (cb);}

AddXXXCallback can dynamically add event callback functions.

The part that actually monitors the NN

Private class MonitorDaemon extends Daemon

It is implemented through the inner class MonitorDaemon. Implemented in the run method, you can see that the run method is called through the source code

Public void run () {while (shouldRun) {try {loopUntilConnected (); doHealthChecks (); / / Monitoring main method} catch (InterruptedException ie) {Preconditions.checkState (! shouldRun, "Interrupted but still supposed to run");}

Carry out monitoring

Let's take a look at this part of the source code:

/ * condition monitoring * @ throws InterruptedException * / private void doHealthChecks () throws InterruptedException {while (shouldRun) {/ / only when shouldRun=false is closed, other states that have always been true HAServiceStatus status = null;//NN boolean healthy = false;// define the health level try {/ / proxy as a rpc agent of HAService, and NameNodeRpcServer implements the NN part of HA status = proxy.getServiceStatus () / / in essence, the monitorHealth method of NN is called, while the monitoring method of NN is mainly a check of system resources. If there is no exception, if there is no exception, the HealthCheckFailedException will be throw if there is an exception, and the AccessControlException exception proxy.monitorHealth (); healthy = true } catch (HealthCheckFailedException e) {/ / exception LOG.warn ("Service health check failed for" + targetToMonitor + ":" + e.getMessage ()); enterState (State.SERVICE_UNHEALTHY);} catch (Throwable t) {/ / unknown exception. Generally, the corresponding NN does not start LOG.warn ("Transport-level exception trying to monitor health of" + targetToMonitor + ":" + t.getLocalizedMessage ()). RPC.stopProxy (proxy); proxy = null; enterState (State.SERVICE_NOT_RESPONDING); Thread.sleep (sleepAfterDisconnectMillis); return;} if (status! = null) {setLastServiceStatus (status);} if (healthy) {/ / set status to notify callback function enterState (State.SERVICE_HEALTHY) } Thread.sleep (checkIntervalMillis);}}

And the monitoring of NN is relatively simple:

Synchronized void monitorHealth () throws HealthCheckFailedException, AccessControlException {namesystem.checkSuperuserPrivilege (); if (! haEnabled) {return; / / no-op, if HA is not enabled} getNamesystem (). CheckAvailableResources (); if (! getNamesystem (). NameNodeHasResourcesAvailable ()) {throw new HealthCheckFailedException ("The NameNode has no resources available");}}

You can see that in fact, the monitoring part is a rpc constantly sending requests for NN to self-detect and then return the corresponding data.

This is the end of the introduction of "what is the principle of hadoop 2.4 namenode ha". 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: 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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report