Examples of HServerAddress


Examples of org.apache.hadoop.hbase.HServerAddress

   */
  @Override
  @QosPriority(priority=HConstants.HIGH_QOS)
  public HServerInfo getHServerInfo() throws IOException {
    checkOpen();
    return new HServerInfo(new HServerAddress(this.isa),
      this.startcode, this.webuiport);
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.HServerAddress

      new TreeMap<HRegionInfo, HServerAddress>();

    final Map<HRegionInfo, ServerName> regionLocations = getRegionLocations();

    for (Map.Entry<HRegionInfo, ServerName> entry : regionLocations.entrySet()) {
      HServerAddress server = new HServerAddress();
      ServerName serverName = entry.getValue();
      if (serverName != null && serverName.getHostAndPort() != null) {
        server = new HServerAddress(Addressing.createInetSocketAddressFromHostAndPortStr(
            serverName.getHostAndPort()));
      }
      regionMap.put(entry.getKey(), server);
    }
View Full Code Here

Examples of org.apache.hadoop.hbase.HServerAddress

    // the first integer is expected to be the size of records
    int regionsCount = in.readInt();
    for (int i = 0; i < regionsCount; ++i) {
      HRegionInfo hri = new HRegionInfo();
      hri.readFields(in);
      HServerAddress hsa = new HServerAddress();
      hsa.readFields(in);
      allRegions.put(hri, hsa);
    }
    return allRegions;
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.HServerAddress

    synchronized (master.regionManager) {
      if (!master.regionManager.isUnassigned(region) &&
          !master.regionManager.isPendingOpen(region.getRegionNameAsString())) {
        if (region.isRootRegion()) {
          // Root region
          HServerAddress rootServer = master.getRootRegionLocation();
          if (rootServer != null) {
            if (rootServer.compareTo(serverInfo.getServerAddress()) == 0) {
              // A duplicate open report from the correct server
              return;
            }
            // We received an open report on the root region, but it is
            // assigned to a different server
            duplicateAssignment = true;
          }
        } else {
          // Not root region. If it is not a pending region, then we are
          // going to treat it as a duplicate assignment, although we can't
          // tell for certain that's the case.
          if (master.regionManager.isPendingOpen(
              region.getRegionNameAsString())) {
            // A duplicate report from the correct server
            return;
          }
          duplicateAssignment = true;
        }
      }
   
      if (duplicateAssignment) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("region server " + serverInfo.getServerAddress().toString()
              + " should not have opened region " + Bytes.toString(region.getRegionName()));
        }

        // This Region should not have been opened.
        // Ask the server to shut it down, but don't report it as closed. 
        // Otherwise the HMaster will think the Region was closed on purpose,
        // and then try to reopen it elsewhere; that's not what we want.
        returnMsgs.add(new HMsg(HMsg.Type.MSG_REGION_CLOSE_WITHOUT_REPORT,
            region, "Duplicate assignment".getBytes()));
      } else {
        if (region.isRootRegion()) {
          // it was assigned, and it's not a duplicate assignment, so take it out
          // of the unassigned list.
          master.regionManager.removeRegion(region);

          // Store the Root Region location (in memory)
          HServerAddress rootServer = serverInfo.getServerAddress();
          if (master.regionManager.inSafeMode()) {
            master.connection.setRootRegionLocation(
                new HRegionLocation(region, rootServer));
          }
          master.regionManager.setRootRegionLocation(rootServer);
View Full Code Here

Examples of org.apache.hadoop.hbase.HServerAddress

      scan(false, null);
      getRegionInfo();
     
      // Store some new information
      HServerAddress address = new HServerAddress("foo.bar.com:1234");

      put = new Put(ROW_KEY);
      put.setTimeStamp(System.currentTimeMillis());
      put.add(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER,
          Bytes.toBytes(address.toString()));

//      put.add(HConstants.COL_STARTCODE, Bytes.toBytes(START_CODE));

      region.put(put);
     
      // Validate that we can still get the HRegionInfo, even though it is in
      // an older row on disk and there is a newer row in the memstore
     
      scan(true, address.toString());
      getRegionInfo();
     
      // flush cache

      region.flushcache();

      // Validate again
     
      scan(true, address.toString());
      getRegionInfo();

      // Close and reopen
     
      r.close();
      r = openClosedRegion(r);
      region = new HRegionIncommon(r);

      // Validate again
     
      scan(true, address.toString());
      getRegionInfo();

      // Now update the information again

      address = new HServerAddress("bar.foo.com:4321");
     
      put = new Put(ROW_KEY);
      put.setTimeStamp(System.currentTimeMillis());

      put.add(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER,
          Bytes.toBytes(address.toString()));
      region.put(put);
     
      // Validate again
     
      scan(true, address.toString());
      getRegionInfo();

      // flush cache

      region.flushcache();

      // Validate again
     
      scan(true, address.toString());
      getRegionInfo();

      // Close and reopen
     
      r.close();
      r = openClosedRegion(r);
      region = new HRegionIncommon(r);

      // Validate again
     
      scan(true, address.toString());
      getRegionInfo();
     
      // clean up
     
      r.close();
View Full Code Here

Examples of org.apache.hadoop.hbase.HServerAddress

    String addressStr = DNS.getDefaultHost(
        conf.get("hbase.master.dns.interface","default"),
        conf.get("hbase.master.dns.nameserver","default"));
    addressStr += ":" +
      conf.get(MASTER_PORT, Integer.toString(DEFAULT_MASTER_PORT));
    HServerAddress address = new HServerAddress(addressStr);
    LOG.info("My address is " + address);

    this.conf = conf;
    this.rootdir = new Path(conf.get(HBASE_DIR));
    try {
      FSUtils.validateRootPath(this.rootdir);
    } catch (IOException e) {
      LOG.fatal("Not starting HMaster because the root directory path '" +
          this.rootdir + "' is not valid. Check the setting of the" +
          " configuration parameter '" + HBASE_DIR + "'", e);
      throw e;
    }
    this.threadWakeFrequency = conf.getInt(THREAD_WAKE_FREQUENCY, 10 * 1000);
    // The filesystem hbase wants to use is probably not what is set into
    // fs.default.name; its value is probably the default.
    this.conf.set("fs.default.name", this.rootdir.toString());
    this.fs = FileSystem.get(conf);
    this.conf.set(HConstants.HBASE_DIR, this.rootdir.toString());
    this.rand = new Random();

    // If FS is in safe mode wait till out of it.
    FSUtils.waitOnSafeMode(this.conf, this.threadWakeFrequency);

    try {
      // Make sure the hbase root directory exists!
      if (!fs.exists(rootdir)) {
        fs.mkdirs(rootdir);
        FSUtils.setVersion(fs, rootdir);
      } else {
        FSUtils.checkVersion(fs, rootdir, true);
      }

      // Make sure the root region directory exists!
      if (!FSUtils.rootRegionExists(fs, rootdir)) {
        bootstrap();
      }
    } catch (IOException e) {
      LOG.fatal("Not starting HMaster because:", e);
      throw e;
    }

    this.numRetries =  conf.getInt("hbase.client.retries.number", 2);
    this.maxRegionOpenTime =
      conf.getLong("hbase.hbasemaster.maxregionopen", 120 * 1000);
    this.leaseTimeout = conf.getInt("hbase.master.lease.period", 120 * 1000);
    this.server = HBaseRPC.getServer(this, address.getBindAddress(),
        address.getPort(), conf.getInt("hbase.regionserver.handler.count", 10),
        false, conf);
        
    //  The rpc-server port can be ephemeral... ensure we have the correct info
    this.address = new HServerAddress(server.getListenerAddress());

    // dont retry too much
    conf.setInt("hbase.client.retries.number", 3);
    this.connection = ServerConnectionManager.getConnection(conf);

View Full Code Here

Examples of org.apache.hadoop.hbase.HServerAddress

  /**
   * @return Location of the <code>-ROOT-</code> region.
   */
  public HServerAddress getRootRegionLocation() {
    HServerAddress rootServer = null;
    if (!shutdownRequested.get() && !closed.get()) {
      rootServer = regionManager.getRootRegionLocation();
    }
    return rootServer;
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.HServerAddress

   * directory and gets their regions assignment.
   */
  private void verifyClusterState()  {
    try {
      LOG.debug("Checking cluster state...");
      HServerAddress rootLocation = zooKeeperWrapper.readRootRegionLocation();
      List<HServerAddress> addresses =  zooKeeperWrapper.scanRSDirectory();
     
      // Check if this is a fresh start of the cluster
      if(addresses.size() == 0) {
        LOG.debug("This is a fresh start, proceeding with normal startup");
        splitLogAfterStartup();
        return;
      }
      LOG.info("This is a failover, ZK inspection begins...");
      boolean isRootRegionAssigned = false;
      Map<byte[], HRegionInfo> assignedRegions =
        new HashMap<byte[], HRegionInfo>();
      // This is a failover case. We must:
      // - 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(
                new HRegionLocation(region, rootLocation));
            regionManager.setRootRegionLocation(rootLocation);
            // Undo the unassign work in the RegionManager constructor
            regionManager.removeRegion(region);
            isRootRegionAssigned = true;
          }
          else if(region.isMetaRegion()) {
            MetaRegion m =
              new MetaRegion(new HServerAddress(address),
                  region);
            regionManager.addMetaRegionToScan(m);
          }
          assignedRegions.put(region.getRegionName(), region);
        }
View Full Code Here

Examples of org.apache.hadoop.hbase.HServerAddress

    // If the address given is not the default one,
    // use the IP given by the user.
    if (serverInfo.getServerAddress().getBindAddress().equals(
        DEFAULT_HOST)) {
      String rsAddress = HBaseServer.getRemoteAddress();
      serverInfo.setServerAddress(new HServerAddress(rsAddress,
        serverInfo.getServerAddress().getPort()));
    }
    // Register with server manager
    this.serverManager.regionServerStartup(serverInfo);
    // Send back some config info
View Full Code Here

Examples of org.apache.hadoop.hbase.HServerAddress

          HRegionInfo info = Writables.getHRegionInfo(
              data.getValue(CATALOG_FAMILY, REGIONINFO_QUALIFIER));
          if (Bytes.compareTo(info.getTableDesc().getName(), tableName) == 0) {
            byte [] value = data.getValue(CATALOG_FAMILY, SERVER_QUALIFIER);
            if (value != null) {
              HServerAddress server =
                new HServerAddress(Bytes.toString(value));
              result.add(new Pair<HRegionInfo,HServerAddress>(info, server));
            }
          } else {
            break;
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.