當前位置: 首頁>>代碼示例>>Java>>正文


Java ServerName.getHostAndPort方法代碼示例

本文整理匯總了Java中org.apache.hadoop.hbase.ServerName.getHostAndPort方法的典型用法代碼示例。如果您正苦於以下問題:Java ServerName.getHostAndPort方法的具體用法?Java ServerName.getHostAndPort怎麽用?Java ServerName.getHostAndPort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.hbase.ServerName的用法示例。


在下文中一共展示了ServerName.getHostAndPort方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isServerDeadAndNotProcessed

import org.apache.hadoop.hbase.ServerName; //導入方法依賴的package包/類
synchronized boolean isServerDeadAndNotProcessed(ServerName server) {
  if (server == null) return false;
  if (serverManager.isServerOnline(server)) {
    String hostAndPort = server.getHostAndPort();
    long startCode = server.getStartcode();
    Long deadCode = deadServers.get(hostAndPort);
    if (deadCode == null || startCode > deadCode.longValue()) {
      if (serverManager.isServerReachable(server)) {
        return false;
      }
      // The size of deadServers won't grow unbounded.
      deadServers.put(hostAndPort, Long.valueOf(startCode));
    }
    // Watch out! If the server is not dead, the region could
    // remain unassigned. That's why ServerManager#isServerReachable
    // should use some retry.
    //
    // We cache this info since it is very unlikely for that
    // instance to come back up later on. We don't want to expire
    // the server since we prefer to let it die naturally.
    LOG.warn("Couldn't reach online server " + server);
  }
  // Now, we know it's dead. Check if it's processed
  return !processedServers.containsKey(server);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:26,代碼來源:RegionStates.java

示例2: toString

import org.apache.hadoop.hbase.ServerName; //導入方法依賴的package包/類
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="SBSC_USE_STRINGBUFFER_CONCATENATION",
    justification="Not important but should be fixed")
@Override
public String toString() {
  String desc = "Cluster{" +
      "servers=[";
      for(ServerName sn:servers) {
         desc += sn.getHostAndPort() + ", ";
      }
      desc +=
      ", serverIndicesSortedByRegionCount="+
      Arrays.toString(serverIndicesSortedByRegionCount) +
      ", regionsPerServer=[";

      for (int[]r:regionsPerServer) {
        desc += Arrays.toString(r);
      }
      desc += "]" +
      ", numMaxRegionsPerTable=" +
      Arrays.toString(numMaxRegionsPerTable) +
      ", numRegions=" +
      numRegions +
      ", numServers=" +
      numServers +
      ", numTables=" +
      numTables +
      ", numMovedRegions=" +
      numMovedRegions +
      '}';
  return desc;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:32,代碼來源:BaseLoadBalancer.java

示例3: countMetaRegions

import org.apache.hadoop.hbase.ServerName; //導入方法依賴的package包/類
private static int countMetaRegions(final HMaster master, final TableName tableName)
    throws IOException {
  final AtomicInteger actualRegCount = new AtomicInteger(0);
  final MetaScannerVisitor visitor = new MetaScannerVisitorBase() {
    @Override
    public boolean processRow(Result rowResult) throws IOException {
      RegionLocations list = MetaTableAccessor.getRegionLocations(rowResult);
      if (list == null) {
        LOG.warn("No serialized HRegionInfo in " + rowResult);
        return true;
      }
      HRegionLocation l = list.getRegionLocation();
      if (l == null) {
        return true;
      }
      if (!l.getRegionInfo().getTable().equals(tableName)) {
        return false;
      }
      if (l.getRegionInfo().isOffline() || l.getRegionInfo().isSplit()) return true;
      HRegionLocation[] locations = list.getRegionLocations();
      for (HRegionLocation location : locations) {
        if (location == null) continue;
        ServerName serverName = location.getServerName();
        // Make sure that regions are assigned to server
        if (serverName != null && serverName.getHostAndPort() != null) {
          actualRegCount.incrementAndGet();
        }
      }
      return true;
    }
  };
  MetaScanner.metaScan(master.getConnection(), visitor, tableName);
  return actualRegCount.get();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:35,代碼來源:MasterProcedureTestingUtility.java

示例4: waitForAllRegionsOnline

import org.apache.hadoop.hbase.ServerName; //導入方法依賴的package包/類
private void waitForAllRegionsOnline(final long deadlineTs)
    throws IOException, TimeoutException {
  final AtomicInteger actualRegCount = new AtomicInteger(0);
  final MetaScannerVisitor visitor = new MetaScannerVisitorBase() {
    @Override
    public boolean processRow(Result rowResult) throws IOException {
      RegionLocations list = MetaTableAccessor.getRegionLocations(rowResult);
      if (list == null) {
        LOG.warn("No serialized HRegionInfo in " + rowResult);
        return true;
      }
      HRegionLocation l = list.getRegionLocation();
      if (l == null) {
        return true;
      }
      if (!l.getRegionInfo().getTable().equals(desc.getTableName())) {
        return false;
      }
      if (l.getRegionInfo().isOffline() || l.getRegionInfo().isSplit()) return true;
      HRegionLocation[] locations = list.getRegionLocations();
      for (HRegionLocation location : locations) {
        if (location == null) continue;
        ServerName serverName = location.getServerName();
        // Make sure that regions are assigned to server
        if (serverName != null && serverName.getHostAndPort() != null) {
          actualRegCount.incrementAndGet();
        }
      }
      return true;
    }
  };

  int tries = 0;
  IOException serverEx = null;
  int numRegs = (splitKeys == null ? 1 : splitKeys.length + 1) * desc.getRegionReplication();
  while (EnvironmentEdgeManager.currentTime() < deadlineTs) {
    actualRegCount.set(0);
    MetaScanner.metaScan(getAdmin().getConnection(), visitor, desc.getTableName());
    if (actualRegCount.get() == numRegs) {
      // all the regions are online
      return;
    }

    try {
      Thread.sleep(getAdmin().getPauseTime(tries++));
    } catch (InterruptedException e) {
      throw new InterruptedIOException("Interrupted when opening" +
        " regions; " + actualRegCount.get() + " of " + numRegs +
        " regions processed so far");
    }
  }
  throw new TimeoutException("Only " + actualRegCount.get() +
          " of " + numRegs + " regions are online; retries exhausted.");
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:55,代碼來源:HBaseAdmin.java


注:本文中的org.apache.hadoop.hbase.ServerName.getHostAndPort方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。