View Javadoc

1   /**
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  package org.apache.hadoop.hbase.zookeeper;
20  
21  import java.io.Closeable;
22  import java.io.IOException;
23  import java.util.ArrayList;
24  import java.util.HashMap;
25  import java.util.List;
26  import java.util.Map;
27  import java.util.concurrent.CopyOnWriteArrayList;
28  import java.util.concurrent.CountDownLatch;
29  
30  import org.apache.commons.logging.Log;
31  import org.apache.commons.logging.LogFactory;
32  import org.apache.hadoop.hbase.classification.InterfaceAudience;
33  import org.apache.hadoop.conf.Configuration;
34  import org.apache.hadoop.hbase.Abortable;
35  import org.apache.hadoop.hbase.HConstants;
36  import org.apache.hadoop.hbase.HRegionInfo;
37  import org.apache.hadoop.hbase.ZooKeeperConnectionException;
38  import org.apache.hadoop.security.UserGroupInformation;
39  import org.apache.zookeeper.KeeperException;
40  import org.apache.zookeeper.WatchedEvent;
41  import org.apache.zookeeper.Watcher;
42  import org.apache.zookeeper.ZooDefs;
43  import org.apache.zookeeper.ZooDefs.Ids;
44  import org.apache.zookeeper.ZooDefs.Perms;
45  import org.apache.zookeeper.data.ACL;
46  import org.apache.zookeeper.data.Id;
47  import org.apache.zookeeper.data.Stat;
48  
49  /**
50   * Acts as the single ZooKeeper Watcher.  One instance of this is instantiated
51   * for each Master, RegionServer, and client process.
52   *
53   * <p>This is the only class that implements {@link Watcher}.  Other internal
54   * classes which need to be notified of ZooKeeper events must register with
55   * the local instance of this watcher via {@link #registerListener}.
56   *
57   * <p>This class also holds and manages the connection to ZooKeeper.  Code to
58   * deal with connection related events and exceptions are handled here.
59   */
60  @InterfaceAudience.Private
61  public class ZooKeeperWatcher implements Watcher, Abortable, Closeable {
62    private static final Log LOG = LogFactory.getLog(ZooKeeperWatcher.class);
63  
64    // Identifier for this watcher (for logging only).  It is made of the prefix
65    // passed on construction and the zookeeper sessionid.
66    private String prefix;
67    private String identifier;
68  
69    // zookeeper quorum
70    private String quorum;
71  
72    // zookeeper connection
73    private RecoverableZooKeeper recoverableZooKeeper;
74  
75    // abortable in case of zk failure
76    protected Abortable abortable;
77    // Used if abortable is null
78    private boolean aborted = false;
79  
80    // listeners to be notified
81    private final List<ZooKeeperListener> listeners =
82      new CopyOnWriteArrayList<ZooKeeperListener>();
83  
84    // Used by ZKUtil:waitForZKConnectionIfAuthenticating to wait for SASL
85    // negotiation to complete
86    public CountDownLatch saslLatch = new CountDownLatch(1);
87  
88    // node names
89  
90    // base znode for this cluster
91    public String baseZNode;
92    //znodes containing the locations of the servers hosting the meta replicas
93    private Map<Integer,String> metaReplicaZnodes = new HashMap<Integer, String>();
94    // znode containing ephemeral nodes of the regionservers
95    public String rsZNode;
96    // znode containing ephemeral nodes of the draining regionservers
97    public String drainingZNode;
98    // znode of currently active master
99    private String masterAddressZNode;
100   // znode of this master in backup master directory, if not the active master
101   public String backupMasterAddressesZNode;
102   // znode containing the current cluster state
103   public String clusterStateZNode;
104   // znode used for region transitioning and assignment
105   public String assignmentZNode;
106   // znode used for table disabling/enabling
107   public String tableZNode;
108   // znode containing the unique cluster ID
109   public String clusterIdZNode;
110   // znode used for log splitting work assignment
111   public String splitLogZNode;
112   // znode containing the state of the load balancer
113   public String balancerZNode;
114   // znode containing the lock for the tables
115   public String tableLockZNode;
116   // znode containing the state of recovering regions
117   public String recoveringRegionsZNode;
118   // znode containing namespace descriptors
119   public static String namespaceZNode = "namespace";
120 
121   // Certain ZooKeeper nodes need to be world-readable
122   public static final ArrayList<ACL> CREATOR_ALL_AND_WORLD_READABLE =
123     new ArrayList<ACL>() { {
124       add(new ACL(ZooDefs.Perms.READ,ZooDefs.Ids.ANYONE_ID_UNSAFE));
125       add(new ACL(ZooDefs.Perms.ALL,ZooDefs.Ids.AUTH_IDS));
126     }};
127 
128   public final static String META_ZNODE_PREFIX = "meta-region-server";
129 
130   private final Configuration conf;
131 
132   private final Exception constructorCaller;
133 
134   /**
135    * Instantiate a ZooKeeper connection and watcher.
136    * @param identifier string that is passed to RecoverableZookeeper to be used as
137    * identifier for this instance. Use null for default.
138    * @throws IOException
139    * @throws ZooKeeperConnectionException
140    */
141   public ZooKeeperWatcher(Configuration conf, String identifier,
142       Abortable abortable) throws ZooKeeperConnectionException, IOException {
143     this(conf, identifier, abortable, false);
144   }
145 
146   /**
147    * Instantiate a ZooKeeper connection and watcher.
148    * @param conf
149    * @param identifier string that is passed to RecoverableZookeeper to be used as identifier for
150    *          this instance. Use null for default.
151    * @param abortable Can be null if there is on error there is no host to abort: e.g. client
152    *          context.
153    * @param canCreateBaseZNode
154    * @throws IOException
155    * @throws ZooKeeperConnectionException
156    */
157   public ZooKeeperWatcher(Configuration conf, String identifier,
158       Abortable abortable, boolean canCreateBaseZNode)
159   throws IOException, ZooKeeperConnectionException {
160     this.conf = conf;
161     // Capture a stack trace now.  Will print it out later if problem so we can
162     // distingush amongst the myriad ZKWs.
163     try {
164       throw new Exception("ZKW CONSTRUCTOR STACK TRACE FOR DEBUGGING");
165     } catch (Exception e) {
166       this.constructorCaller = e;
167     }
168     this.quorum = ZKConfig.getZKQuorumServersString(conf);
169     this.prefix = identifier;
170     // Identifier will get the sessionid appended later below down when we
171     // handle the syncconnect event.
172     this.identifier = identifier + "0x0";
173     this.abortable = abortable;
174     setNodeNames(conf);
175     this.recoverableZooKeeper = ZKUtil.connect(conf, quorum, this, identifier);
176     if (canCreateBaseZNode) {
177       createBaseZNodes();
178     }
179   }
180 
181   private void createBaseZNodes() throws ZooKeeperConnectionException {
182     try {
183       // Create all the necessary "directories" of znodes
184       ZKUtil.createWithParents(this, baseZNode);
185       if (conf.getBoolean("hbase.assignment.usezk", true)) {
186         ZKUtil.createAndFailSilent(this, assignmentZNode);
187       }
188       ZKUtil.createAndFailSilent(this, rsZNode);
189       ZKUtil.createAndFailSilent(this, drainingZNode);
190       ZKUtil.createAndFailSilent(this, tableZNode);
191       ZKUtil.createAndFailSilent(this, splitLogZNode);
192       ZKUtil.createAndFailSilent(this, backupMasterAddressesZNode);
193       ZKUtil.createAndFailSilent(this, tableLockZNode);
194       ZKUtil.createAndFailSilent(this, recoveringRegionsZNode);
195     } catch (KeeperException e) {
196       throw new ZooKeeperConnectionException(
197           prefix("Unexpected KeeperException creating base node"), e);
198     }
199   }
200 
201   /** Returns whether the znode is supposed to be readable by the client
202    * and DOES NOT contain sensitive information (world readable).*/
203   public boolean isClientReadable(String node) {
204     // Developer notice: These znodes are world readable. DO NOT add more znodes here UNLESS
205     // all clients need to access this data to work. Using zk for sharing data to clients (other
206     // than service lookup case is not a recommended design pattern.
207     return
208         node.equals(baseZNode) ||
209         isAnyMetaReplicaZnode(node) ||
210         node.equals(getMasterAddressZNode()) ||
211         node.equals(clusterIdZNode)||
212         node.equals(rsZNode) ||
213         // /hbase/table and /hbase/table/foo is allowed, /hbase/table-lock is not
214         node.equals(tableZNode) ||
215         node.startsWith(tableZNode + "/");
216   }
217 
218   /**
219    * On master start, we check the znode ACLs under the root directory and set the ACLs properly
220    * if needed. If the cluster goes from an unsecure setup to a secure setup, this step is needed
221    * so that the existing znodes created with open permissions are now changed with restrictive
222    * perms.
223    */
224   public void checkAndSetZNodeAcls() {
225     if (!ZKUtil.isSecureZooKeeper(getConfiguration())) {
226       return;
227     }
228 
229     // Check the base znodes permission first. Only do the recursion if base znode's perms are not
230     // correct.
231     try {
232       List<ACL> actualAcls = recoverableZooKeeper.getAcl(baseZNode, new Stat());
233 
234       if (!isBaseZnodeAclSetup(actualAcls)) {
235         LOG.info("setting znode ACLs");
236         setZnodeAclsRecursive(baseZNode);
237       }
238     } catch(KeeperException.NoNodeException nne) {
239       return;
240     } catch(InterruptedException ie) {
241       interruptedException(ie);
242     } catch (IOException|KeeperException e) {
243       LOG.warn("Received exception while checking and setting zookeeper ACLs", e);
244     }
245   }
246 
247   /**
248    * Set the znode perms recursively. This will do post-order recursion, so that baseZnode ACLs
249    * will be set last in case the master fails in between.
250    * @param znode
251    */
252   private void setZnodeAclsRecursive(String znode) throws KeeperException, InterruptedException {
253     List<String> children = recoverableZooKeeper.getChildren(znode, false);
254 
255     for (String child : children) {
256       setZnodeAclsRecursive(ZKUtil.joinZNode(znode, child));
257     }
258     List<ACL> acls = ZKUtil.createACL(this, znode, true);
259     LOG.info("Setting ACLs for znode:" + znode + " , acl:" + acls);
260     recoverableZooKeeper.setAcl(znode, acls, -1);
261   }
262 
263   /**
264    * Checks whether the ACLs returned from the base znode (/hbase) is set for secure setup.
265    * @param acls acls from zookeeper
266    * @return whether ACLs are set for the base znode
267    * @throws IOException
268    */
269   private boolean isBaseZnodeAclSetup(List<ACL> acls) throws IOException {
270     String superUser = conf.get("hbase.superuser");
271 
272     // this assumes that current authenticated user is the same as zookeeper client user
273     // configured via JAAS
274     String hbaseUser = UserGroupInformation.getCurrentUser().getShortUserName();
275 
276     if (acls.isEmpty()) {
277       return false;
278     }
279 
280     for (ACL acl : acls) {
281       int perms = acl.getPerms();
282       Id id = acl.getId();
283       // We should only set at most 3 possible ACLs for 3 Ids. One for everyone, one for superuser
284       // and one for the hbase user
285       if (Ids.ANYONE_ID_UNSAFE.equals(id)) {
286         if (perms != Perms.READ) {
287           return false;
288         }
289       } else if (superUser != null && new Id("sasl", superUser).equals(id)) {
290         if (perms != Perms.ALL) {
291           return false;
292         }
293       } else if (new Id("sasl", hbaseUser).equals(id)) {
294         if (perms != Perms.ALL) {
295           return false;
296         }
297       } else {
298         return false;
299       }
300     }
301     return true;
302   }
303 
304   @Override
305   public String toString() {
306     return this.identifier + ", quorum=" + quorum + ", baseZNode=" + baseZNode;
307   }
308 
309   /**
310    * Adds this instance's identifier as a prefix to the passed <code>str</code>
311    * @param str String to amend.
312    * @return A new string with this instance's identifier as prefix: e.g.
313    * if passed 'hello world', the returned string could be
314    */
315   public String prefix(final String str) {
316     return this.toString() + " " + str;
317   }
318 
319   /**
320    * Set the local variable node names using the specified configuration.
321    */
322   private void setNodeNames(Configuration conf) {
323     baseZNode = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT,
324         HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
325     metaReplicaZnodes.put(0, ZKUtil.joinZNode(baseZNode,
326            conf.get("zookeeper.znode.metaserver", "meta-region-server")));
327     int numMetaReplicas = conf.getInt(HConstants.META_REPLICAS_NUM,
328             HConstants.DEFAULT_META_REPLICA_NUM);
329     for (int i = 1; i < numMetaReplicas; i++) {
330       String str = ZKUtil.joinZNode(baseZNode,
331         conf.get("zookeeper.znode.metaserver", "meta-region-server") + "-" + i);
332       metaReplicaZnodes.put(i, str);
333     }
334     rsZNode = ZKUtil.joinZNode(baseZNode,
335         conf.get("zookeeper.znode.rs", "rs"));
336     drainingZNode = ZKUtil.joinZNode(baseZNode,
337         conf.get("zookeeper.znode.draining.rs", "draining"));
338     masterAddressZNode = ZKUtil.joinZNode(baseZNode,
339         conf.get("zookeeper.znode.master", "master"));
340     backupMasterAddressesZNode = ZKUtil.joinZNode(baseZNode,
341         conf.get("zookeeper.znode.backup.masters", "backup-masters"));
342     clusterStateZNode = ZKUtil.joinZNode(baseZNode,
343         conf.get("zookeeper.znode.state", "running"));
344     assignmentZNode = ZKUtil.joinZNode(baseZNode,
345         conf.get("zookeeper.znode.unassigned", "region-in-transition"));
346     tableZNode = ZKUtil.joinZNode(baseZNode,
347         conf.get("zookeeper.znode.tableEnableDisable", "table"));
348     clusterIdZNode = ZKUtil.joinZNode(baseZNode,
349         conf.get("zookeeper.znode.clusterId", "hbaseid"));
350     splitLogZNode = ZKUtil.joinZNode(baseZNode,
351         conf.get("zookeeper.znode.splitlog", HConstants.SPLIT_LOGDIR_NAME));
352     balancerZNode = ZKUtil.joinZNode(baseZNode,
353         conf.get("zookeeper.znode.balancer", "balancer"));
354     tableLockZNode = ZKUtil.joinZNode(baseZNode,
355         conf.get("zookeeper.znode.tableLock", "table-lock"));
356     recoveringRegionsZNode = ZKUtil.joinZNode(baseZNode,
357         conf.get("zookeeper.znode.recovering.regions", "recovering-regions"));
358     namespaceZNode = ZKUtil.joinZNode(baseZNode,
359         conf.get("zookeeper.znode.namespace", "namespace"));
360   }
361 
362   /**
363    * Is the znode of any meta replica
364    * @param node
365    * @return true or false
366    */
367   public boolean isAnyMetaReplicaZnode(String node) {
368     if (metaReplicaZnodes.values().contains(node)) {
369       return true;
370     }
371     return false;
372   }
373 
374   /**
375    * Is it the default meta replica's znode
376    * @param node
377    * @return true or false
378    */
379   public boolean isDefaultMetaReplicaZnode(String node) {
380     if (getZNodeForReplica(HRegionInfo.DEFAULT_REPLICA_ID).equals(node)) {
381       return true;
382     }
383     return false;
384   }
385 
386   /**
387    * Get the znodes corresponding to the meta replicas from ZK
388    * @return list of znodes
389    * @throws KeeperException
390    */
391   public List<String> getMetaReplicaNodes() throws KeeperException {
392     List<String> childrenOfBaseNode = ZKUtil.listChildrenNoWatch(this, baseZNode);
393     List<String> metaReplicaNodes = new ArrayList<String>(2);
394     String pattern = conf.get("zookeeper.znode.metaserver","meta-region-server");
395     for (String child : childrenOfBaseNode) {
396       if (child.startsWith(pattern)) metaReplicaNodes.add(child);
397     }
398     return metaReplicaNodes;
399   }
400 
401   /**
402    * Get the znode string corresponding to a replicaId
403    * @param replicaId
404    * @return znode
405    */
406   public String getZNodeForReplica(int replicaId) {
407     String str = metaReplicaZnodes.get(replicaId);
408     // return a newly created path but don't update the cache of paths
409     // This is mostly needed for tests that attempt to create meta replicas
410     // from outside the master
411     if (str == null) {
412       str = ZKUtil.joinZNode(baseZNode,
413           conf.get("zookeeper.znode.metaserver", "meta-region-server") + "-" + replicaId);
414     }
415     return str;
416   }
417 
418   /**
419    * Parse the meta replicaId from the passed znode
420    * @param znode
421    * @return replicaId
422    */
423   public int getMetaReplicaIdFromZnode(String znode) {
424     String pattern = conf.get("zookeeper.znode.metaserver","meta-region-server");
425     if (znode.equals(pattern)) return HRegionInfo.DEFAULT_REPLICA_ID;
426     // the non-default replicas are of the pattern meta-region-server-<replicaId>
427     String nonDefaultPattern = pattern + "-";
428     return Integer.parseInt(znode.substring(nonDefaultPattern.length()));
429   }
430 
431   /**
432    * Register the specified listener to receive ZooKeeper events.
433    * @param listener
434    */
435   public void registerListener(ZooKeeperListener listener) {
436     listeners.add(listener);
437   }
438 
439   /**
440    * Register the specified listener to receive ZooKeeper events and add it as
441    * the first in the list of current listeners.
442    * @param listener
443    */
444   public void registerListenerFirst(ZooKeeperListener listener) {
445     listeners.add(0, listener);
446   }
447 
448   public void unregisterListener(ZooKeeperListener listener) {
449     listeners.remove(listener);
450   }
451 
452   /**
453    * Clean all existing listeners
454    */
455   public void unregisterAllListeners() {
456     listeners.clear();
457   }
458 
459   /**
460    * Get a copy of current registered listeners
461    */
462   public List<ZooKeeperListener> getListeners() {
463     return new ArrayList<ZooKeeperListener>(listeners);
464   }
465 
466   /**
467    * @return The number of currently registered listeners
468    */
469   public int getNumberOfListeners() {
470     return listeners.size();
471   }
472 
473   /**
474    * Get the connection to ZooKeeper.
475    * @return connection reference to zookeeper
476    */
477   public RecoverableZooKeeper getRecoverableZooKeeper() {
478     return recoverableZooKeeper;
479   }
480 
481   public void reconnectAfterExpiration() throws IOException, KeeperException, InterruptedException {
482     recoverableZooKeeper.reconnectAfterExpiration();
483   }
484 
485   /**
486    * Get the quorum address of this instance.
487    * @return quorum string of this zookeeper connection instance
488    */
489   public String getQuorum() {
490     return quorum;
491   }
492 
493   /**
494    * @return the base znode of this zookeeper connection instance.
495    */
496   public String getBaseZNode() {
497     return baseZNode;
498   }
499 
500   /**
501    * Method called from ZooKeeper for events and connection status.
502    * <p>
503    * Valid events are passed along to listeners.  Connection status changes
504    * are dealt with locally.
505    */
506   @Override
507   public void process(WatchedEvent event) {
508     LOG.debug(prefix("Received ZooKeeper Event, " +
509         "type=" + event.getType() + ", " +
510         "state=" + event.getState() + ", " +
511         "path=" + event.getPath()));
512 
513     switch(event.getType()) {
514 
515       // If event type is NONE, this is a connection status change
516       case None: {
517         connectionEvent(event);
518         break;
519       }
520 
521       // Otherwise pass along to the listeners
522 
523       case NodeCreated: {
524         for(ZooKeeperListener listener : listeners) {
525           listener.nodeCreated(event.getPath());
526         }
527         break;
528       }
529 
530       case NodeDeleted: {
531         for(ZooKeeperListener listener : listeners) {
532           listener.nodeDeleted(event.getPath());
533         }
534         break;
535       }
536 
537       case NodeDataChanged: {
538         for(ZooKeeperListener listener : listeners) {
539           listener.nodeDataChanged(event.getPath());
540         }
541         break;
542       }
543 
544       case NodeChildrenChanged: {
545         for(ZooKeeperListener listener : listeners) {
546           listener.nodeChildrenChanged(event.getPath());
547         }
548         break;
549       }
550     }
551   }
552 
553   // Connection management
554 
555   /**
556    * Called when there is a connection-related event via the Watcher callback.
557    * <p>
558    * If Disconnected or Expired, this should shutdown the cluster. But, since
559    * we send a KeeperException.SessionExpiredException along with the abort
560    * call, it's possible for the Abortable to catch it and try to create a new
561    * session with ZooKeeper. This is what the client does in HCM.
562    * <p>
563    * @param event
564    */
565   private void connectionEvent(WatchedEvent event) {
566     switch(event.getState()) {
567       case SyncConnected:
568         // Now, this callback can be invoked before the this.zookeeper is set.
569         // Wait a little while.
570         long finished = System.currentTimeMillis() +
571           this.conf.getLong("hbase.zookeeper.watcher.sync.connected.wait", 2000);
572         while (System.currentTimeMillis() < finished) {
573           try {
574             Thread.sleep(1);
575           } catch (InterruptedException e) {
576             LOG.warn("Interrupted while sleeping");
577             throw new RuntimeException("Interrupted while waiting for" +
578                 " recoverableZooKeeper is set");
579           }
580           if (this.recoverableZooKeeper != null) break;
581         }
582 
583         if (this.recoverableZooKeeper == null) {
584           LOG.error("ZK is null on connection event -- see stack trace " +
585             "for the stack trace when constructor was called on this zkw",
586             this.constructorCaller);
587           throw new NullPointerException("ZK is null");
588         }
589         this.identifier = this.prefix + "-0x" +
590           Long.toHexString(this.recoverableZooKeeper.getSessionId());
591         // Update our identifier.  Otherwise ignore.
592         LOG.debug(this.identifier + " connected");
593         break;
594 
595       // Abort the server if Disconnected or Expired
596       case Disconnected:
597         LOG.debug(prefix("Received Disconnected from ZooKeeper, ignoring"));
598         break;
599 
600       case Expired:
601         String msg = prefix(this.identifier + " received expired from " +
602           "ZooKeeper, aborting");
603         // TODO: One thought is to add call to ZooKeeperListener so say,
604         // ZooKeeperNodeTracker can zero out its data values.
605         if (this.abortable != null) {
606           this.abortable.abort(msg, new KeeperException.SessionExpiredException());
607         }
608         break;
609 
610       case ConnectedReadOnly:
611       case SaslAuthenticated:
612       case AuthFailed:
613         break;
614 
615       default:
616         throw new IllegalStateException("Received event is not valid: " + event.getState());
617     }
618   }
619 
620   /**
621    * Forces a synchronization of this ZooKeeper client connection.
622    * <p>
623    * Executing this method before running other methods will ensure that the
624    * subsequent operations are up-to-date and consistent as of the time that
625    * the sync is complete.
626    * <p>
627    * This is used for compareAndSwap type operations where we need to read the
628    * data of an existing node and delete or transition that node, utilizing the
629    * previously read version and data.  We want to ensure that the version read
630    * is up-to-date from when we begin the operation.
631    */
632   public void sync(String path) throws KeeperException {
633     this.recoverableZooKeeper.sync(path, null, null);
634   }
635 
636   /**
637    * Handles KeeperExceptions in client calls.
638    * <p>
639    * This may be temporary but for now this gives one place to deal with these.
640    * <p>
641    * TODO: Currently this method rethrows the exception to let the caller handle
642    * <p>
643    * @param ke
644    * @throws KeeperException
645    */
646   public void keeperException(KeeperException ke)
647   throws KeeperException {
648     LOG.error(prefix("Received unexpected KeeperException, re-throwing exception"), ke);
649     throw ke;
650   }
651 
652   /**
653    * Handles InterruptedExceptions in client calls.
654    * <p>
655    * This may be temporary but for now this gives one place to deal with these.
656    * <p>
657    * TODO: Currently, this method does nothing.
658    *       Is this ever expected to happen?  Do we abort or can we let it run?
659    *       Maybe this should be logged as WARN?  It shouldn't happen?
660    * <p>
661    * @param ie
662    */
663   public void interruptedException(InterruptedException ie) {
664     LOG.debug(prefix("Received InterruptedException, doing nothing here"), ie);
665     // At least preserver interrupt.
666     Thread.currentThread().interrupt();
667     // no-op
668   }
669 
670   /**
671    * Close the connection to ZooKeeper.
672    *
673    * @throws InterruptedException
674    */
675   @Override
676   public void close() {
677     try {
678       if (recoverableZooKeeper != null) {
679         recoverableZooKeeper.close();
680       }
681     } catch (InterruptedException e) {
682       Thread.currentThread().interrupt();
683     }
684   }
685 
686   public Configuration getConfiguration() {
687     return conf;
688   }
689 
690   @Override
691   public void abort(String why, Throwable e) {
692     if (this.abortable != null) this.abortable.abort(why, e);
693     else this.aborted = true;
694   }
695 
696   @Override
697   public boolean isAborted() {
698     return this.abortable == null? this.aborted: this.abortable.isAborted();
699   }
700 
701   /**
702    * @return Path to the currently active master.
703    */
704   public String getMasterAddressZNode() {
705     return this.masterAddressZNode;
706   }
707 
708 }