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 http://www.apache.org/licenses/LICENSE-2.0 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.master;
Wrapper over the rack resolution utility in Hadoop. The rack resolution utility in Hadoop does resolution from hosts to the racks they belong to.
public class RackManager {
  static final Log LOG = LogFactory.getLog(RackManager.class);
  public static final String UNKNOWN_RACK = "Unknown Rack";
  public RackManager(Configuration conf) {
     = ReflectionUtils.instantiateWithCustomCtor(
        conf.getClass("hbase.util.ip.to.rack.determiner"ScriptBasedMapping.class,
             DNSToSwitchMapping.class).getName(), new Class<?>[]{Configuration.class},
               new Object[]{conf});
  }

  
Get the name of the rack containing a server, according to the DNS to switch mapping.

Parameters:
server the server for which to get the rack name
Returns:
the rack name of the server
  public String getRack(ServerName server) {
    if (server == null) {
      return ;
    }
    // just a note - switchMapping caches results (at least the implementation should unless the
    // resolution is really a lightweight process)
    List<Stringracks = .resolve(Arrays.asList(server.getHostname()));
    if (racks != null && !racks.isEmpty()) {
      return racks.get(0);
    }
    return ;
  }
New to GrepCode? Check out our FAQ X