Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 package org.apache.hadoop.hbase.zookeeper;
 import java.util.List;
Tracks the list of draining region servers via ZK.

This class is responsible for watching for changes to the draining servers list. It handles adds/deletes in the draining RS list and watches each node.

If an RS gets deleted from draining list, we call org.apache.hadoop.hbase.master.ServerManager.removeServerFromDrainList(org.apache.hadoop.hbase.ServerName)

If an RS gets added to the draining list, we add a watcher to it and call org.apache.hadoop.hbase.master.ServerManager.addServerToDrainList(org.apache.hadoop.hbase.ServerName)

 public class DrainingServerTracker extends ZooKeeperListener {
   private static final Log LOG = LogFactory.getLog(DrainingServerTracker.class);
   private final NavigableSet<ServerNamedrainingServers = new TreeSet<ServerName>();
   private Abortable abortable;
       Abortable abortableServerManager serverManager) {
     this. = abortable;
     this. = serverManager;

Starts the tracking of draining RegionServers.

All Draining RSs will be tracked after this method is called.

   public void start() throws KeeperExceptionIOException {
     List<Stringservers =
   private void add(final List<Stringserversthrows IOException {
     synchronized(this.) {
       for (String nservers) {
         final ServerName sn = ServerName.valueOf(ZKUtil.getNodeName(n));
         .info("Draining RS node created, adding to list [" +
             sn + "]");
   private void remove(final ServerName sn) {
     synchronized(this.) {
   public void nodeDeleted(final String path) {
     if(path.startsWith(.)) {
      final ServerName sn = ServerName.valueOf(ZKUtil.getNodeName(path));
      .info("Draining RS node deleted, removing from list [" +
          sn + "]");
  public void nodeChildrenChanged(final String path) {
    if(path.equals(.)) {
      try {
        final List<StringnewNodes =
      } catch (KeeperException e) {
        .abort("Unexpected zk exception getting RS nodes"e);
      } catch (IOException e) {
        .abort("Unexpected zk exception getting RS nodes"e);
New to GrepCode? Check out our FAQ X