Java 类org.apache.hadoop.hbase.ipc.HMasterRegionInterface 实例源码

项目:LCIndex-HBase-0.94.16    文件:HMaster.java   
@Override
public ProtocolSignature getProtocolSignature(
    String protocol, long version, int clientMethodsHashCode)
throws IOException {
  if (HMasterInterface.class.getName().equals(protocol)) {
    return new ProtocolSignature(HMasterInterface.VERSION, null);
  } else if (HMasterRegionInterface.class.getName().equals(protocol)) {
    return new ProtocolSignature(HMasterRegionInterface.VERSION, null);
  }
  throw new IOException("Unknown protocol: " + protocol);
}
项目:LCIndex-HBase-0.94.16    文件:HMaster.java   
public long getProtocolVersion(String protocol, long clientVersion) {
  if (HMasterInterface.class.getName().equals(protocol)) {
    return HMasterInterface.VERSION;
  } else if (HMasterRegionInterface.class.getName().equals(protocol)) {
    return HMasterRegionInterface.VERSION;
  }
  // unknown protocol
  LOG.warn("Version requested for unimplemented protocol: "+protocol);
  return -1;
}
项目:IRIndex    文件:HMaster.java   
@Override
public ProtocolSignature getProtocolSignature(
    String protocol, long version, int clientMethodsHashCode)
throws IOException {
  if (HMasterInterface.class.getName().equals(protocol)) {
    return new ProtocolSignature(HMasterInterface.VERSION, null);
  } else if (HMasterRegionInterface.class.getName().equals(protocol)) {
    return new ProtocolSignature(HMasterRegionInterface.VERSION, null);
  }
  throw new IOException("Unknown protocol: " + protocol);
}
项目:IRIndex    文件:HMaster.java   
public long getProtocolVersion(String protocol, long clientVersion) {
  if (HMasterInterface.class.getName().equals(protocol)) {
    return HMasterInterface.VERSION;
  } else if (HMasterRegionInterface.class.getName().equals(protocol)) {
    return HMasterRegionInterface.VERSION;
  }
  // unknown protocol
  LOG.warn("Version requested for unimplemented protocol: "+protocol);
  return -1;
}
项目:RStore    文件:HMaster.java   
@Override
public ProtocolSignature getProtocolSignature(
    String protocol, long version, int clientMethodsHashCode)
throws IOException {
  if (HMasterInterface.class.getName().equals(protocol)) {
    return new ProtocolSignature(HMasterInterface.VERSION, null);
  } else if (HMasterRegionInterface.class.getName().equals(protocol)) {
    return new ProtocolSignature(HMasterRegionInterface.VERSION, null);
  }
  throw new IOException("Unknown protocol: " + protocol);
}
项目:RStore    文件:HMaster.java   
public long getProtocolVersion(String protocol, long clientVersion) {
  if (HMasterInterface.class.getName().equals(protocol)) {
    return HMasterInterface.VERSION;
  } else if (HMasterRegionInterface.class.getName().equals(protocol)) {
    return HMasterRegionInterface.VERSION;
  }
  // unknown protocol
  LOG.warn("Version requested for unimplemented protocol: "+protocol);
  return -1;
}
项目:HBase-Research    文件:HMaster.java   
@Override
public ProtocolSignature getProtocolSignature(
    String protocol, long version, int clientMethodsHashCode)
throws IOException {
  if (HMasterInterface.class.getName().equals(protocol)) {
    return new ProtocolSignature(HMasterInterface.VERSION, null);
  } else if (HMasterRegionInterface.class.getName().equals(protocol)) {
    return new ProtocolSignature(HMasterRegionInterface.VERSION, null);
  }
  throw new IOException("Unknown protocol: " + protocol);
}
项目:HBase-Research    文件:HMaster.java   
public long getProtocolVersion(String protocol, long clientVersion) {
  if (HMasterInterface.class.getName().equals(protocol)) {
    return HMasterInterface.VERSION;
  } else if (HMasterRegionInterface.class.getName().equals(protocol)) {
    return HMasterRegionInterface.VERSION;
  }
  // unknown protocol
  LOG.warn("Version requested for unimplemented protocol: "+protocol);
  return -1;
}
项目:hbase-0.94.8-qod    文件:HMaster.java   
@Override
public ProtocolSignature getProtocolSignature(
    String protocol, long version, int clientMethodsHashCode)
throws IOException {
  if (HMasterInterface.class.getName().equals(protocol)) {
    return new ProtocolSignature(HMasterInterface.VERSION, null);
  } else if (HMasterRegionInterface.class.getName().equals(protocol)) {
    return new ProtocolSignature(HMasterRegionInterface.VERSION, null);
  }
  throw new IOException("Unknown protocol: " + protocol);
}
项目:hbase-0.94.8-qod    文件:HMaster.java   
public long getProtocolVersion(String protocol, long clientVersion) {
  if (HMasterInterface.class.getName().equals(protocol)) {
    return HMasterInterface.VERSION;
  } else if (HMasterRegionInterface.class.getName().equals(protocol)) {
    return HMasterRegionInterface.VERSION;
  }
  // unknown protocol
  LOG.warn("Version requested for unimplemented protocol: "+protocol);
  return -1;
}
项目:hbase-0.94.8-qod    文件:HMaster.java   
@Override
public ProtocolSignature getProtocolSignature(
    String protocol, long version, int clientMethodsHashCode)
throws IOException {
  if (HMasterInterface.class.getName().equals(protocol)) {
    return new ProtocolSignature(HMasterInterface.VERSION, null);
  } else if (HMasterRegionInterface.class.getName().equals(protocol)) {
    return new ProtocolSignature(HMasterRegionInterface.VERSION, null);
  }
  throw new IOException("Unknown protocol: " + protocol);
}
项目:hbase-0.94.8-qod    文件:HMaster.java   
public long getProtocolVersion(String protocol, long clientVersion) {
  if (HMasterInterface.class.getName().equals(protocol)) {
    return HMasterInterface.VERSION;
  } else if (HMasterRegionInterface.class.getName().equals(protocol)) {
    return HMasterRegionInterface.VERSION;
  }
  // unknown protocol
  LOG.warn("Version requested for unimplemented protocol: "+protocol);
  return -1;
}
项目:hindex    文件:HMaster.java   
@Override
public ProtocolSignature getProtocolSignature(
    String protocol, long version, int clientMethodsHashCode)
throws IOException {
  if (HMasterInterface.class.getName().equals(protocol)) {
    return new ProtocolSignature(HMasterInterface.VERSION, null);
  } else if (HMasterRegionInterface.class.getName().equals(protocol)) {
    return new ProtocolSignature(HMasterRegionInterface.VERSION, null);
  }
  throw new IOException("Unknown protocol: " + protocol);
}
项目:hindex    文件:HMaster.java   
public long getProtocolVersion(String protocol, long clientVersion) {
  if (HMasterInterface.class.getName().equals(protocol)) {
    return HMasterInterface.VERSION;
  } else if (HMasterRegionInterface.class.getName().equals(protocol)) {
    return HMasterRegionInterface.VERSION;
  }
  // unknown protocol
  LOG.warn("Version requested for unimplemented protocol: "+protocol);
  return -1;
}
项目:LCIndex-HBase-0.94.16    文件:HRegionServer.java   
/**
 * Get the current master from ZooKeeper and open the RPC connection to it. Method will block
 * until a master is available. You can break from this block by requesting the server stop.
 * @return master + port, or null if server has been stopped
 */
private ServerName getMaster() {
  ServerName masterServerName = null;
  long previousLogTime = 0;
  HMasterRegionInterface master = null;
  InetSocketAddress masterIsa = null;
  while (keepLooping() && master == null) {
    masterServerName = this.masterAddressManager.getMasterAddress();
    if (masterServerName == null) {
      if (!keepLooping()) {
        // give up with no connection.
        LOG.debug("No master found and cluster is stopped; bailing out");
        return null;
      }
      LOG.debug("No master found; retry");
      previousLogTime = System.currentTimeMillis();

      sleeper.sleep();
      continue;
    }

    masterIsa = new InetSocketAddress(masterServerName.getHostname(), masterServerName.getPort());

    LOG.info("Attempting connect to Master server at " + masterServerName);
    try {
      // Do initial RPC setup. The final argument indicates that the RPC
      // should retry indefinitely.
      master =
          HBaseRPC.waitForProxy(this.rpcEngine, HMasterRegionInterface.class,
            HMasterRegionInterface.VERSION, masterIsa, this.conf, -1, this.rpcTimeout,
            this.rpcTimeout);
    } catch (IOException e) {
      e = e instanceof RemoteException ? ((RemoteException) e).unwrapRemoteException() : e;
      if (e instanceof ServerNotRunningYetException) {
        if (System.currentTimeMillis() > (previousLogTime + 1000)) {
          LOG.info("Master isn't available yet, retrying");
          previousLogTime = System.currentTimeMillis();
        }
      } else {
        if (System.currentTimeMillis() > (previousLogTime + 1000)) {
          LOG.warn("Unable to connect to master. Retrying. Error was:", e);
          previousLogTime = System.currentTimeMillis();
        }
      }
      try {
        Thread.sleep(200);
      } catch (InterruptedException ignored) {
      }
    }
  }
  LOG.info("Connected to master at " + masterIsa);
  this.hbaseMaster = master;
  return masterServerName;
}
项目:IRIndex    文件:HRegionServer.java   
/**
 * Get the current master from ZooKeeper and open the RPC connection to it.
 *
 * Method will block until a master is available. You can break from this
 * block by requesting the server stop.
 *
 * @return master + port, or null if server has been stopped
 */
private ServerName getMaster() {
  ServerName masterServerName = null;
  long previousLogTime = 0;
  HMasterRegionInterface master = null;
  InetSocketAddress masterIsa = null;
  while (keepLooping() && master == null) {
    masterServerName = this.masterAddressManager.getMasterAddress();
    if (masterServerName == null) {
      if (!keepLooping()) {
        // give up with no connection.
        LOG.debug("No master found and cluster is stopped; bailing out");
        return null;
      }
      LOG.debug("No master found; retry");
      previousLogTime = System.currentTimeMillis();

      sleeper.sleep();
      continue;
    }

    masterIsa =
      new InetSocketAddress(masterServerName.getHostname(), masterServerName.getPort());

    LOG.info("Attempting connect to Master server at " + masterServerName);
    try {
      // Do initial RPC setup. The final argument indicates that the RPC
      // should retry indefinitely.
      master = HBaseRPC.waitForProxy(this.rpcEngine,
          HMasterRegionInterface.class, HMasterRegionInterface.VERSION,
          masterIsa, this.conf, -1,
          this.rpcTimeout, this.rpcTimeout);
    } catch (IOException e) {
      e = e instanceof RemoteException ?
          ((RemoteException)e).unwrapRemoteException() : e;
      if (e instanceof ServerNotRunningYetException) {
        if (System.currentTimeMillis() > (previousLogTime+1000)){
          LOG.info("Master isn't available yet, retrying");
          previousLogTime = System.currentTimeMillis();
        }
      } else {
        if (System.currentTimeMillis() > (previousLogTime + 1000)) {
          LOG.warn("Unable to connect to master. Retrying. Error was:", e);
          previousLogTime = System.currentTimeMillis();
        }
      }
      try {
        Thread.sleep(200);
      } catch (InterruptedException ignored) {
      }
    }
  }
  LOG.info("Connected to master at " + masterIsa);
  this.hbaseMaster = master;
  return masterServerName;
}
项目:RStore    文件:HMaster.java   
/**
 * Initializes the HMaster. The steps are as follows:
 * <p>
 * <ol>
 * <li>Initialize HMaster RPC and address
 * <li>Connect to ZooKeeper.
 * </ol>
 * <p>
 * Remaining steps of initialization occur in {@link #run()} so that they
 * run in their own thread rather than within the context of the constructor.
 * @throws InterruptedException
 */
public HMaster(final Configuration conf)
throws IOException, KeeperException, InterruptedException {
  this.conf = new Configuration(conf);
  // Disable the block cache on the master
  this.conf.setFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, 0.0f);
  // Set how many times to retry talking to another server over HConnection.
  HConnectionManager.setServerSideHConnectionRetries(this.conf, LOG);
  // Server to handle client requests.
  String hostname = DNS.getDefaultHost(
    conf.get("hbase.master.dns.interface", "default"),
    conf.get("hbase.master.dns.nameserver", "default"));
  int port = conf.getInt(HConstants.MASTER_PORT, HConstants.DEFAULT_MASTER_PORT);
  // Creation of a HSA will force a resolve.
  InetSocketAddress initialIsa = new InetSocketAddress(hostname, port);
  if (initialIsa.getAddress() == null) {
    throw new IllegalArgumentException("Failed resolve of " + this.isa);
  }
  int numHandlers = conf.getInt("hbase.master.handler.count",
    conf.getInt("hbase.regionserver.handler.count", 25));
  this.rpcServer = HBaseRPC.getServer(this,
    new Class<?>[]{HMasterInterface.class, HMasterRegionInterface.class},
      initialIsa.getHostName(), // BindAddress is IP we got for this server.
      initialIsa.getPort(),
      numHandlers,
      0, // we dont use high priority handlers in master
      conf.getBoolean("hbase.rpc.verbose", false), conf,
      0); // this is a DNC w/o high priority handlers
  // Set our address.
  this.isa = this.rpcServer.getListenerAddress();
  this.serverName = new ServerName(this.isa.getHostName(),
    this.isa.getPort(), System.currentTimeMillis());
  this.rsFatals = new MemoryBoundedLogMessageBuffer(
      conf.getLong("hbase.master.buffer.for.rs.fatals", 1*1024*1024));

  // initialize server principal (if using secure Hadoop)
  User.login(conf, "hbase.master.keytab.file",
    "hbase.master.kerberos.principal", this.isa.getHostName());

  // set the thread name now we have an address
  setName(MASTER + "-" + this.serverName.toString());

  Replication.decorateMasterConfiguration(this.conf);

  // Hack! Maps DFSClient => Master for logs.  HDFS made this
  // config param for task trackers, but we can piggyback off of it.
  if (this.conf.get("mapred.task.id") == null) {
    this.conf.set("mapred.task.id", "hb_m_" + this.serverName.toString());
  }

  this.zooKeeper = new ZooKeeperWatcher(conf, MASTER + ":" + isa.getPort(), this, true);
  this.rpcServer.startThreads();
  this.metrics = new MasterMetrics(getServerName().toString());
}
项目:HBase-Research    文件:HMaster.java   
/**
 * Initializes the HMaster. The steps are as follows:
 * <p>
 * <ol>
 * <li>Initialize HMaster RPC and address
 * <li>Connect to ZooKeeper.
 * </ol>
 * <p>
 * Remaining steps of initialization occur in {@link #run()} so that they
 * run in their own thread rather than within the context of the constructor.
 * @throws InterruptedException
 */
public HMaster(final Configuration conf)
throws IOException, KeeperException, InterruptedException {
  this.conf = new Configuration(conf);
  // Disable the block cache on the master
  this.conf.setFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, 0.0f);
  // Set how many times to retry talking to another server over HConnection.
  HConnectionManager.setServerSideHConnectionRetries(this.conf, LOG);
  // Server to handle client requests.
  String hostname = conf.get("hbase.master.ipc.address",
    Strings.domainNamePointerToHostName(DNS.getDefaultHost(
      conf.get("hbase.master.dns.interface", "default"),
      conf.get("hbase.master.dns.nameserver", "default"))));
  int port = conf.getInt(HConstants.MASTER_PORT, HConstants.DEFAULT_MASTER_PORT);
  // Test that the hostname is reachable
  InetSocketAddress initialIsa = new InetSocketAddress(hostname, port);
  if (initialIsa.getAddress() == null) {
    throw new IllegalArgumentException("Failed resolve of hostname " + initialIsa);
  }
  int numHandlers = conf.getInt("hbase.master.handler.count",
    conf.getInt("hbase.regionserver.handler.count", 25));
  this.rpcServer = HBaseRPC.getServer(this,
    new Class<?>[]{HMasterInterface.class, HMasterRegionInterface.class},
      initialIsa.getHostName(), // This is bindAddress if set else it's hostname
      initialIsa.getPort(),
      numHandlers,
      0, // we dont use high priority handlers in master
      conf.getBoolean("hbase.rpc.verbose", false), conf,
      0); // this is a DNC w/o high priority handlers
  // Set our address.
  this.isa = this.rpcServer.getListenerAddress();
  this.serverName = new ServerName(this.isa.getHostName(),
    this.isa.getPort(), System.currentTimeMillis());
  this.rsFatals = new MemoryBoundedLogMessageBuffer(
      conf.getLong("hbase.master.buffer.for.rs.fatals", 1*1024*1024));

  // login the zookeeper client principal (if using security)
  ZKUtil.loginClient(this.conf, "hbase.zookeeper.client.keytab.file",
    "hbase.zookeeper.client.kerberos.principal", this.isa.getHostName());

  // initialize server principal (if using secure Hadoop)
  User.login(conf, "hbase.master.keytab.file",
    "hbase.master.kerberos.principal", this.isa.getHostName());

  // set the thread name now we have an address
  setName(MASTER + "-" + this.serverName.toString());

  Replication.decorateMasterConfiguration(this.conf);

  // Hack! Maps DFSClient => Master for logs.  HDFS made this
  // config param for task trackers, but we can piggyback off of it.
  if (this.conf.get("mapred.task.id") == null) {
    this.conf.set("mapred.task.id", "hb_m_" + this.serverName.toString());
  }

  this.zooKeeper = new ZooKeeperWatcher(conf, MASTER + ":" + isa.getPort(), this, true);
  this.rpcServer.startThreads();
  this.metrics = new MasterMetrics(getServerName().toString());

  // Health checker thread.
  int sleepTime = this.conf.getInt(HConstants.HEALTH_CHORE_WAKE_FREQ,
    HConstants.DEFAULT_THREAD_WAKE_FREQUENCY);
  if (isHealthCheckerConfigured()) {
    healthCheckChore = new HealthCheckChore(sleepTime, this, getConfiguration());
  }

  this.shouldSplitMetaSeparately = conf.getBoolean(HLog.SEPARATE_HLOG_FOR_META, false);
  waitingOnLogSplitting = this.conf.getBoolean("hbase.master.wait.for.log.splitting", false);
}
项目:HBase-Research    文件:HRegionServer.java   
/**
 * Get the current master from ZooKeeper and open the RPC connection to it.
 *
 * Method will block until a master is available. You can break from this
 * block by requesting the server stop.
 *
 * @return master + port, or null if server has been stopped
 */
private ServerName getMaster() {
  ServerName masterServerName = null;
  long previousLogTime = 0;
  HMasterRegionInterface master = null;
  InetSocketAddress masterIsa = null;
  while (keepLooping() && master == null) {
    masterServerName = this.masterAddressManager.getMasterAddress();
    if (masterServerName == null) {
      if (!keepLooping()) {
        // give up with no connection.
        LOG.debug("No master found and cluster is stopped; bailing out");
        return null;
      }
      LOG.debug("No master found; retry");
      previousLogTime = System.currentTimeMillis();

      sleeper.sleep();
      continue;
    }

    masterIsa =
      new InetSocketAddress(masterServerName.getHostname(), masterServerName.getPort());

    LOG.info("Attempting connect to Master server at " +
      this.masterAddressManager.getMasterAddress());
    try {
      // Do initial RPC setup. The final argument indicates that the RPC
      // should retry indefinitely.
      master = HBaseRPC.waitForProxy(this.rpcEngine,
          HMasterRegionInterface.class, HMasterRegionInterface.VERSION,
          masterIsa, this.conf, -1,
          this.rpcTimeout, this.rpcTimeout);
    } catch (IOException e) {
      e = e instanceof RemoteException ?
          ((RemoteException)e).unwrapRemoteException() : e;
      if (e instanceof ServerNotRunningYetException) {
        if (System.currentTimeMillis() > (previousLogTime+1000)){
          LOG.info("Master isn't available yet, retrying");
          previousLogTime = System.currentTimeMillis();
        }
      } else {
        if (System.currentTimeMillis() > (previousLogTime + 1000)) {
          LOG.warn("Unable to connect to master. Retrying. Error was:", e);
          previousLogTime = System.currentTimeMillis();
        }
      }
      try {
        Thread.sleep(200);
      } catch (InterruptedException ignored) {
      }
    }
  }
  LOG.info("Connected to master at " + masterIsa);
  this.hbaseMaster = master;
  return masterServerName;
}
项目:hbase-0.94.8-qod    文件:HRegionServer.java   
/**
 * Get the current master from ZooKeeper and open the RPC connection to it.
 *
 * Method will block until a master is available. You can break from this
 * block by requesting the server stop.
 *
 * @return master + port, or null if server has been stopped
 */
private ServerName getMaster() {
  ServerName masterServerName = null;
  long previousLogTime = 0;
  HMasterRegionInterface master = null;
  InetSocketAddress masterIsa = null;
  while (keepLooping() && master == null) {
    masterServerName = this.masterAddressManager.getMasterAddress();
    if (masterServerName == null) {
      if (!keepLooping()) {
        // give up with no connection.
        LOG.debug("No master found and cluster is stopped; bailing out");
        return null;
      }
      LOG.debug("No master found; retry");
      previousLogTime = System.currentTimeMillis();

      sleeper.sleep();
      continue;
    }

    masterIsa =
      new InetSocketAddress(masterServerName.getHostname(), masterServerName.getPort());

    LOG.info("Attempting connect to Master server at " +
      this.masterAddressManager.getMasterAddress());
    try {
      // Do initial RPC setup. The final argument indicates that the RPC
      // should retry indefinitely.
      master = HBaseRPC.waitForProxy(this.rpcEngine,
          HMasterRegionInterface.class, HMasterRegionInterface.VERSION,
          masterIsa, this.conf, -1,
          this.rpcTimeout, this.rpcTimeout);
    } catch (IOException e) {
      e = e instanceof RemoteException ?
          ((RemoteException)e).unwrapRemoteException() : e;
      if (e instanceof ServerNotRunningYetException) {
        if (System.currentTimeMillis() > (previousLogTime+1000)){
          LOG.info("Master isn't available yet, retrying");
          previousLogTime = System.currentTimeMillis();
        }
      } else {
        if (System.currentTimeMillis() > (previousLogTime + 1000)) {
          LOG.warn("Unable to connect to master. Retrying. Error was:", e);
          previousLogTime = System.currentTimeMillis();
        }
      }
      try {
        Thread.sleep(200);
      } catch (InterruptedException ignored) {
      }
    }
  }
  LOG.info("Connected to master at " + masterIsa);
  this.hbaseMaster = master;
  return masterServerName;
}
项目:hbase-0.94.8-qod    文件:HRegionServer.java   
/**
 * Get the current master from ZooKeeper and open the RPC connection to it.
 *
 * Method will block until a master is available. You can break from this
 * block by requesting the server stop.
 *
 * @return master + port, or null if server has been stopped
 */
private ServerName getMaster() {
  ServerName masterServerName = null;
  long previousLogTime = 0;
  HMasterRegionInterface master = null;
  InetSocketAddress masterIsa = null;
  while (keepLooping() && master == null) {
    masterServerName = this.masterAddressManager.getMasterAddress();
    if (masterServerName == null) {
      if (!keepLooping()) {
        // give up with no connection.
        LOG.debug("No master found and cluster is stopped; bailing out");
        return null;
      }
      LOG.debug("No master found; retry");
      previousLogTime = System.currentTimeMillis();

      sleeper.sleep();
      continue;
    }

    masterIsa =
      new InetSocketAddress(masterServerName.getHostname(), masterServerName.getPort());

    LOG.info("Attempting connect to Master server at " +
      this.masterAddressManager.getMasterAddress());
    try {
      // Do initial RPC setup. The final argument indicates that the RPC
      // should retry indefinitely.
      master = HBaseRPC.waitForProxy(this.rpcEngine,
          HMasterRegionInterface.class, HMasterRegionInterface.VERSION,
          masterIsa, this.conf, -1,
          this.rpcTimeout, this.rpcTimeout);
    } catch (IOException e) {
      e = e instanceof RemoteException ?
          ((RemoteException)e).unwrapRemoteException() : e;
      if (e instanceof ServerNotRunningYetException) {
        if (System.currentTimeMillis() > (previousLogTime+1000)){
          LOG.info("Master isn't available yet, retrying");
          previousLogTime = System.currentTimeMillis();
        }
      } else {
        if (System.currentTimeMillis() > (previousLogTime + 1000)) {
          LOG.warn("Unable to connect to master. Retrying. Error was:", e);
          previousLogTime = System.currentTimeMillis();
        }
      }
      try {
        Thread.sleep(200);
      } catch (InterruptedException ignored) {
      }
    }
  }
  LOG.info("Connected to master at " + masterIsa);
  this.hbaseMaster = master;
  return masterServerName;
}
项目:hindex    文件:HRegionServer.java   
/**
 * Get the current master from ZooKeeper and open the RPC connection to it.
 *
 * Method will block until a master is available. You can break from this
 * block by requesting the server stop.
 *
 * @return master + port, or null if server has been stopped
 */
private ServerName getMaster() {
  ServerName masterServerName = null;
  long previousLogTime = 0;
  HMasterRegionInterface master = null;
  InetSocketAddress masterIsa = null;
  while (keepLooping() && master == null) {
    masterServerName = this.masterAddressManager.getMasterAddress();
    if (masterServerName == null) {
      if (!keepLooping()) {
        // give up with no connection.
        LOG.debug("No master found and cluster is stopped; bailing out");
        return null;
      }
      LOG.debug("No master found; retry");
      previousLogTime = System.currentTimeMillis();

      sleeper.sleep();
      continue;
    }

    masterIsa =
      new InetSocketAddress(masterServerName.getHostname(), masterServerName.getPort());

    LOG.info("Attempting connect to Master server at " +
      this.masterAddressManager.getMasterAddress());
    try {
      // Do initial RPC setup. The final argument indicates that the RPC
      // should retry indefinitely.
      master = HBaseRPC.waitForProxy(this.rpcEngine,
          HMasterRegionInterface.class, HMasterRegionInterface.VERSION,
          masterIsa, this.conf, -1,
          this.rpcTimeout, this.rpcTimeout);
    } catch (IOException e) {
      e = e instanceof RemoteException ?
          ((RemoteException)e).unwrapRemoteException() : e;
      if (e instanceof ServerNotRunningYetException) {
        if (System.currentTimeMillis() > (previousLogTime+1000)){
          LOG.info("Master isn't available yet, retrying");
          previousLogTime = System.currentTimeMillis();
        }
      } else {
        if (System.currentTimeMillis() > (previousLogTime + 1000)) {
          LOG.warn("Unable to connect to master. Retrying. Error was:", e);
          previousLogTime = System.currentTimeMillis();
        }
      }
      try {
        Thread.sleep(200);
      } catch (InterruptedException ignored) {
      }
    }
  }
  LOG.info("Connected to master at " + masterIsa);
  this.hbaseMaster = master;
  return masterServerName;
}