Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.HServerInfo$LoadComparator


   * @throws IOException
   */
  public HMsg [] regionServerReport(final HServerInfo serverInfo,
    final HMsg msgs[], final HRegionInfo[] mostLoadedRegions)
  throws IOException {
    HServerInfo info = new HServerInfo(serverInfo);
    if (isDead(info.getServerName())) {
      throw new Leases.LeaseStillHeldException(info.getServerName());
    }
    if (msgs.length > 0) {
      if (msgs[0].isType(HMsg.Type.MSG_REPORT_EXITING)) {
        processRegionServerExit(info, msgs);
        return EMPTY_HMSG_ARRAY;
      } else if (msgs[0].isType(HMsg.Type.MSG_REPORT_QUIESCED)) {
        LOG.info("Region server " + info.getServerName() + " quiesced");
        quiescedServers.incrementAndGet();
      }
    }

    if (master.shutdownRequested.get()) {
      if (quiescedServers.get() >= serversToServerInfo.size()) {
        // If the only servers we know about are meta servers, then we can
        // proceed with shutdown
        LOG.info("All user tables quiesced. Proceeding with shutdown");
        master.startShutdown();
      }

      if (!master.closed.get()) {
        if (msgs.length > 0 &&
            msgs[0].isType(HMsg.Type.MSG_REPORT_QUIESCED)) {
          // Server is already quiesced, but we aren't ready to shut down
          // return empty response
          return EMPTY_HMSG_ARRAY;
        }
        // Tell the server to stop serving any user regions
        return new HMsg [] {REGIONSERVER_QUIESCE};
      }
    }

    if (master.closed.get()) {
      // Tell server to shut down if we are shutting down.  This should
      // happen after check of MSG_REPORT_EXITING above, since region server
      // will send us one of these messages after it gets MSG_REGIONSERVER_STOP
      return new HMsg [] {REGIONSERVER_STOP};
    }

    HServerInfo storedInfo = serversToServerInfo.get(info.getServerName());
    if (storedInfo == null) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Received report from unknown server -- telling it " +
          "to " + CALL_SERVER_STARTUP + ": " + info.getServerName());
      }

      // The HBaseMaster may have been restarted.
      // Tell the RegionServer to start over and call regionServerStartup()
      return new HMsg[] {CALL_SERVER_STARTUP};
    } else if (storedInfo.getStartCode() != info.getStartCode()) {
      // This state is reachable if:
      //
      // 1) RegionServer A started
      // 2) RegionServer B started on the same machine, then
      //    clobbered A in regionServerStartup.
View Full Code Here


  /** Update a server load information because it's shutting down*/
  private boolean removeServerInfo(final String serverName,
                                   final HServerAddress serverAddress) {
    boolean infoUpdated = false;
    serverAddressToServerInfo.remove(serverAddress);
    HServerInfo info = serversToServerInfo.remove(serverName);
    // Only update load information once.
    // This method can be called a couple of times during shutdown.
    if (info != null) {
      LOG.info("Removing server's info " + serverName);
      master.regionManager.offlineMetaServer(info.getServerAddress());

      infoUpdated = true;

      // update load information
      HServerLoad load = serversToLoad.remove(serverName);
View Full Code Here

    public void process(WatchedEvent event) {
      if(event.getType().equals(EventType.NodeDeleted)) {
        LOG.info(server + " znode expired");
        // Remove the server from the known servers list and update load info
        serverAddressToServerInfo.remove(serverAddress);
        HServerInfo info = serversToServerInfo.remove(server);
        if (info != null) {
          String serverName = HServerInfo.getServerName(info);
          HServerLoad load = serversToLoad.remove(serverName);
          if (load != null) {
            synchronized (loadToServers) {
View Full Code Here

      }
    }
    if (sa != null && sa.length() > 0) {
      serverName = HServerInfo.getServerName(sa, sc);
    }
    HServerInfo storedInfo = null;
    synchronized (this.master.regionManager) {
      /* We don't assign regions that are offline, in transition or were on
       * a dead server. Regions that were on a dead server will get reassigned
       * by ProcessServerShutdown
       */
 
View Full Code Here

      address.getPort(), conf.getInt("hbase.regionserver.handler.count", 10),
      false, conf);
    this.server.setErrorHandler(this);
    // Address is giving a default IP for the moment. Will be changed after
    // calling the master.
    this.serverInfo = new HServerInfo(new HServerAddress(
      new InetSocketAddress(address.getBindAddress(),
      this.server.getListenerAddress().getPort())), System.currentTimeMillis(),
      this.conf.getInt("hbase.regionserver.info.port", 60030), machineName);
    if (this.serverInfo.getServerAddress() == null) {
      throw new NullPointerException("Server address cannot be null; " +
View Full Code Here

  }
 
  protected boolean isBeingServed(String serverName) {
    boolean result = false;
    if (serverName != null && serverName.length() > 0) {
      HServerInfo s = master.serverManager.getServerInfo(serverName);
      result = s != null;
    }
    return result;
  }
View Full Code Here

      // - contact every region server to add them to the regionservers list
      // - get their current regions assignment
      for (HServerAddress address : addresses) {
        HRegionInterface hri =
          this.connection.getHRegionConnection(address, false);
        HServerInfo info = hri.getHServerInfo();
        LOG.debug("Inspection found server " + info.getName());
        serverManager.recordNewServer(info, true);
        HRegionInfo[] regions = hri.getRegionsAssignment();
        for (HRegionInfo region : regions) {
          if(region.isRootRegion()) {
            connection.setRootRegionLocation(
View Full Code Here

  }

  protected void checkAssigned(final HRegionInfo info,
    final String serverName, final long startCode)
  throws IOException {
     HServerInfo storedInfo = null;
    synchronized (this.master.regionManager) {
      /*
       * We don't assign regions that are offline, in transition or were on
       * a dead server. Regions that were on a dead server will get reassigned
       * by ProcessServerShutdown
       */
      if (info.isOffline() ||
          this.master.regionManager.
            regionIsInTransition(info.getRegionName()) ||
          (serverName != null && this.master.serverManager.isDead(serverName))) {

        return;
      }
      if (serverName != null && serverName.length() != 0) {
        storedInfo = this.master.serverManager.getServerInfo(serverName);
      }

      /*
       * If the startcode is off -- either null or doesn't match the start code
       * for the address -- then add it to the list of unassigned regions.
       */
      if (storedInfo == null || storedInfo.getStartCode() != startCode) {

        // The current assignment is invalid
        if (LOG.isDebugEnabled()) {
          LOG.debug("Current assignment of " + info.getRegionNameAsString() +
            " is not valid; " +
            (storedInfo == null ? " Server '" + serverName + "' unknown." :
                " serverInfo: " + storedInfo + ", passed startCode: " +
                startCode + ", storedInfo.startCode: " +
                storedInfo.getStartCode()));
        }

        // Recover the region server's log if there is one.
        // This is only done from here if we are restarting and there is stale
        // data in the meta region. Once we are on-line, dead server log
View Full Code Here

    String machineName = DNS.getDefaultHost(
        conf.get("hbase.regionserver.dns.interface","default"),
        conf.get("hbase.regionserver.dns.nameserver","default"));
    // Address is givin a default IP for the moment. Will be changed after
    // calling the master.
    this.serverInfo = new HServerInfo(new HServerAddress(
      new InetSocketAddress(address.getBindAddress(),
      this.server.getListenerAddress().getPort())), System.currentTimeMillis(),
      this.conf.getInt("hbase.regionserver.info.port", 60030), machineName);
   
    if (this.serverInfo.getServerAddress() == null) {
View Full Code Here

          servers.remove(s);
          loadToServers.put(load, servers);
        }
      }
    }
    HServerInfo storedInfo = serversToServerInfo.remove(s);
    if (storedInfo != null && !master.closed.get()) {
      // The startup message was from a known server with the same name.
      // Timeout the old one right away.
      HServerAddress root = master.getRootRegionLocation();
      boolean rootServer = false;
      if (root != null && root.equals(storedInfo.getServerAddress())) {
        master.regionManager.unsetRootRegion();
        rootServer = true;
      }
      try {
        master.toDoQueue.put(
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.HServerInfo$LoadComparator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.