当前位置: 首页>>代码示例>>Java>>正文


Java MetaScannerVisitorBase类代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase的典型用法代码示例。如果您正苦于以下问题:Java MetaScannerVisitorBase类的具体用法?Java MetaScannerVisitorBase怎么用?Java MetaScannerVisitorBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MetaScannerVisitorBase类属于org.apache.hadoop.hbase.client.MetaScanner包,在下文中一共展示了MetaScannerVisitorBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isTableAvailable

import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase; //导入依赖的package包/类
public boolean isTableAvailable(final byte[] tableName) throws IOException {
  final AtomicBoolean available = new AtomicBoolean(true);
  final AtomicInteger regionCount = new AtomicInteger(0);
  MetaScannerVisitor visitor = new MetaScannerVisitorBase() {
    @Override
    public boolean processRow(Result row) throws IOException {
      byte[] value = row.getValue(HConstants.CATALOG_FAMILY,
          HConstants.REGIONINFO_QUALIFIER);
      HRegionInfo info = Writables.getHRegionInfoOrNull(value);
      if (info != null && !info.isSplitParent()) {
        if (Bytes.equals(tableName, info.getTableName())) {
          value = row.getValue(HConstants.CATALOG_FAMILY,
              HConstants.SERVER_QUALIFIER);
          if (value == null) {
            available.set(false);
            return false;
          }
          regionCount.incrementAndGet();
        }
      }
      return true;
    }
  };
  MetaScanner.metaScan(conf, this, visitor, null);
  return available.get() && (regionCount.get() > 0);
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:27,代码来源:HConnectionManager.java

示例2: isTableAvailable

import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase; //导入依赖的package包/类
public boolean isTableAvailable(final byte[] tableName) throws IOException {
  final AtomicBoolean available = new AtomicBoolean(true);
  final AtomicInteger regionCount = new AtomicInteger(0);
  MetaScannerVisitor visitor = new MetaScannerVisitorBase() {
    @Override
    public boolean processRow(Result row) throws IOException {
      byte[] value = row.getValue(HConstants.CATALOG_FAMILY,
          HConstants.REGIONINFO_QUALIFIER);
      HRegionInfo info = Writables.getHRegionInfoOrNull(value);
      if (info != null) {
        if (Bytes.equals(tableName, info.getTableName())) {
          value = row.getValue(HConstants.CATALOG_FAMILY,
              HConstants.SERVER_QUALIFIER);
          if (value == null) {
            available.set(false);
            return false;
          }
          regionCount.incrementAndGet();
        }
      }
      return true;
    }
  };
  MetaScanner.metaScan(conf, visitor);
  return available.get() && (regionCount.get() > 0);
}
 
开发者ID:zwqjsj0404,项目名称:HBase-Research,代码行数:27,代码来源:HConnectionManager.java

示例3: isTableAvailable

import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase; //导入依赖的package包/类
@Override
public boolean isTableAvailable(final byte[] tableName) throws IOException {
  final AtomicBoolean available = new AtomicBoolean(true);
  final AtomicInteger regionCount = new AtomicInteger(0);
  MetaScannerVisitor visitor = new MetaScannerVisitorBase() {
    @Override
    public boolean processRow(Result row) throws IOException {
      HRegionInfo info = MetaScanner.getHRegionInfo(row);
      if (info != null) {
        if (Bytes.equals(tableName, info.getTableName())) {
          ServerName server = HRegionInfo.getServerName(row);
          if (server == null) {
            available.set(false);
            return false;
          }
          regionCount.incrementAndGet();
        }
      }
      return true;
    }
  };
  MetaScanner.metaScan(conf, visitor);
  return available.get() && (regionCount.get() > 0);
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:25,代码来源:HConnectionManager.java

示例4: getTableRegionForRow

import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase; //导入依赖的package包/类
/**
 * Return the region and current deployment for the region containing
 * the given row. If the region cannot be found, returns null. If it
 * is found, but not currently deployed, the second element of the pair
 * may be null.
 */
@VisibleForTesting // Used by TestMaster.
Pair<HRegionInfo, ServerName> getTableRegionForRow(
    final TableName tableName, final byte [] rowKey)
throws IOException {
  final AtomicReference<Pair<HRegionInfo, ServerName>> result =
    new AtomicReference<Pair<HRegionInfo, ServerName>>(null);

  MetaScannerVisitor visitor =
    new MetaScannerVisitorBase() {
      @Override
      public boolean processRow(Result data) throws IOException {
        if (data == null || data.size() <= 0) {
          return true;
        }
        Pair<HRegionInfo, ServerName> pair = HRegionInfo.getHRegionInfoAndServerName(data);
        if (pair == null) {
          return false;
        }
        if (!pair.getFirst().getTable().equals(tableName)) {
          return false;
        }
        result.set(pair);
        return true;
      }
  };

  MetaScanner.metaScan(clusterConnection, visitor, tableName, rowKey, 1);
  return result.get();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:36,代码来源:HMaster.java

示例5: countMetaRegions

import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase; //导入依赖的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

示例6: getRegion

import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase; //导入依赖的package包/类
/**
 * @param regionName Name of a region.
 * @return a pair of HRegionInfo and ServerName if <code>regionName</code> is
 *  a verified region name (we call {@link
 *  MetaTableAccessor#getRegion(HConnection, byte[])}
 *  else null.
 * Throw IllegalArgumentException if <code>regionName</code> is null.
 * @throws IOException
 */
Pair<HRegionInfo, ServerName> getRegion(final byte[] regionName) throws IOException {
  if (regionName == null) {
    throw new IllegalArgumentException("Pass a table name or region name");
  }
  Pair<HRegionInfo, ServerName> pair =
    MetaTableAccessor.getRegion(connection, regionName);
  if (pair == null) {
    final AtomicReference<Pair<HRegionInfo, ServerName>> result =
      new AtomicReference<Pair<HRegionInfo, ServerName>>(null);
    final String encodedName = Bytes.toString(regionName);
    MetaScannerVisitor visitor = new MetaScannerVisitorBase() {
      @Override
      public boolean processRow(Result data) throws IOException {
        HRegionInfo info = HRegionInfo.getHRegionInfo(data);
        if (info == null) {
          LOG.warn("No serialized HRegionInfo in " + data);
          return true;
        }
        RegionLocations rl = MetaTableAccessor.getRegionLocations(data);
        boolean matched = false;
        ServerName sn = null;
        for (HRegionLocation h : rl.getRegionLocations()) {
          if (h != null && encodedName.equals(h.getRegionInfo().getEncodedName())) {
            sn = h.getServerName();
            info = h.getRegionInfo();
            matched = true;
          }
        }
        if (!matched) return true;
        result.set(new Pair<HRegionInfo, ServerName>(info, sn));
        return false; // found the region, stop
      }
    };

    MetaScanner.metaScan(connection, visitor, null);
    pair = result.get();
  }
  return pair;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:49,代码来源:HBaseAdmin.java

示例7: isTableAvailable

import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase; //导入依赖的package包/类
@Override
public boolean isTableAvailable(final TableName tableName) throws IOException {
  final AtomicBoolean available = new AtomicBoolean(true);
  final AtomicInteger regionCount = new AtomicInteger(0);
  MetaScannerVisitor visitor = new MetaScannerVisitorBase() {
    @Override
    public boolean processRow(Result row) throws IOException {
      HRegionInfo info = MetaScanner.getHRegionInfo(row);
      if (info != null && !info.isSplitParent()) {
        if (tableName.equals(info.getTable())) {
          ServerName server = HRegionInfo.getServerName(row);
          if (server == null) {
            available.set(false);
            return false;
          }
          regionCount.incrementAndGet();
        } else if (tableName.compareTo(info.getTable()) < 0) {
          // Return if we are done with the current table
          return false;
        }
      }
      return true;
    }
  };
  MetaScanner.metaScan(this, visitor, tableName);
  return available.get() && (regionCount.get() > 0);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:28,代码来源:ConnectionManager.java

示例8: getRegion

import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase; //导入依赖的package包/类
/**
 * @param tableNameOrRegionName Name of a table or name of a region.
 * @param ct A {@link CatalogTracker} instance (caller of this method usually has one).
 * @return a pair of HRegionInfo and ServerName if <code>tableNameOrRegionName</code> is a
 *         verified region name (we call {@link MetaReader#getRegion(CatalogTracker, byte[])} else
 *         null. Throw an exception if <code>tableNameOrRegionName</code> is null.
 * @throws IOException
 */
Pair<HRegionInfo, ServerName> getRegion(final byte[] tableNameOrRegionName,
    final CatalogTracker ct) throws IOException {
  if (tableNameOrRegionName == null) {
    throw new IllegalArgumentException("Pass a table name or region name");
  }
  Pair<HRegionInfo, ServerName> pair = MetaReader.getRegion(ct, tableNameOrRegionName);
  if (pair == null) {
    final AtomicReference<Pair<HRegionInfo, ServerName>> result = new AtomicReference<Pair<HRegionInfo, ServerName>>(
        null);
    final String encodedName = Bytes.toString(tableNameOrRegionName);
    MetaScannerVisitor visitor = new MetaScannerVisitorBase() {
      @Override
      public boolean processRow(Result data) throws IOException {
        if (data == null || data.size() <= 0) {
          return true;
        }
        HRegionInfo info = MetaReader.parseHRegionInfoFromCatalogResult(data,
          HConstants.REGIONINFO_QUALIFIER);
        if (info == null) {
          LOG.warn("No serialized HRegionInfo in " + data);
          return true;
        }
        if (!encodedName.equals(info.getEncodedName())) return true;
        ServerName sn = MetaReader.getServerNameFromCatalogResult(data);
        result.set(new Pair<HRegionInfo, ServerName>(info, sn));
        return false; // found the region, stop
      }
    };

    MetaScanner.metaScan(conf, connection, visitor, null);
    pair = result.get();
  }
  return pair;
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:43,代码来源:HBaseAdmin.java

示例9: getTableRegionForRow

import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase; //导入依赖的package包/类
/**
 * Return the region and current deployment for the region containing
 * the given row. If the region cannot be found, returns null. If it
 * is found, but not currently deployed, the second element of the pair
 * may be null.
 */
Pair<HRegionInfo, ServerName> getTableRegionForRow(
    final byte [] tableName, final byte [] rowKey)
throws IOException {
  final AtomicReference<Pair<HRegionInfo, ServerName>> result =
    new AtomicReference<Pair<HRegionInfo, ServerName>>(null);

  MetaScannerVisitor visitor =
    new MetaScannerVisitorBase() {
      @Override
      public boolean processRow(Result data) throws IOException {
        if (data == null || data.size() <= 0) {
          return true;
        }
        Pair<HRegionInfo, ServerName> pair = MetaReader.parseCatalogResult(data);
        if (pair == null) {
          return false;
        }
        if (!Bytes.equals(pair.getFirst().getTableName(), tableName)) {
          return false;
        }
        result.set(pair);
        return true;
      }
  };

  MetaScanner.metaScan(conf, visitor, tableName, rowKey, 1);
  return result.get();
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:35,代码来源:HMaster.java

示例10: getTableRegionForRow

import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase; //导入依赖的package包/类
/**
 * Return the region and current deployment for the region containing
 * the given row. If the region cannot be found, returns null. If it
 * is found, but not currently deployed, the second element of the pair
 * may be null.
 */
@VisibleForTesting
// Used by TestMaster.
Pair<HRegionInfo, ServerName> getTableRegionForRow(
        final TableName tableName, final byte[] rowKey)
        throws IOException {
    final AtomicReference<Pair<HRegionInfo, ServerName>> result =
            new AtomicReference<Pair<HRegionInfo, ServerName>>(null);

    MetaScannerVisitor visitor =
            new MetaScannerVisitorBase() {
                @Override
                public boolean processRow(Result data) throws IOException {
                    if (data == null || data.size() <= 0) {
                        return true;
                    }
                    Pair<HRegionInfo, ServerName> pair = HRegionInfo.getHRegionInfoAndServerName(data);
                    if (pair == null) {
                        return false;
                    }
                    if (!pair.getFirst().getTable().equals(tableName)) {
                        return false;
                    }
                    result.set(pair);
                    return true;
                }
            };

    MetaScanner.metaScan(clusterConnection, visitor, tableName, rowKey, 1);
    return result.get();
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:37,代码来源:HMaster.java

示例11: getRegion

import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase; //导入依赖的package包/类
/**
 * @param regionName Name of a region.
 * @return a pair of HRegionInfo and ServerName if <code>regionName</code> is
 *  a verified region name (we call {@link
 *  MetaTableAccessor#getRegion(HConnection, byte[])}
 *  else null.
 * Throw IllegalArgumentException if <code>regionName</code> is null.
 * @throws IOException
 */
Pair<HRegionInfo, ServerName> getRegion(final byte[] regionName) throws IOException {
  if (regionName == null) {
    throw new IllegalArgumentException("Pass a table name or region name");
  }
  Pair<HRegionInfo, ServerName> pair =
    MetaTableAccessor.getRegion(connection, regionName);
  if (pair == null) {
    final AtomicReference<Pair<HRegionInfo, ServerName>> result =
      new AtomicReference<Pair<HRegionInfo, ServerName>>(null);
    final String encodedName = Bytes.toString(regionName);
    MetaScannerVisitor visitor = new MetaScannerVisitorBase() {
      @Override
      public boolean processRow(Result data) throws IOException {
        HRegionInfo info = HRegionInfo.getHRegionInfo(data);
        if (info == null) {
          LOG.warn("No serialized HRegionInfo in " + data);
          return true;
        }
        if (!encodedName.equals(info.getEncodedName())) return true;
        ServerName sn = HRegionInfo.getServerName(data);
        result.set(new Pair<HRegionInfo, ServerName>(info, sn));
        return false; // found the region, stop
      }
    };

    MetaScanner.metaScan(connection, visitor, null);
    pair = result.get();
  }
  return pair;
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:40,代码来源:HBaseAdmin.java

示例12: isTableAvailable

import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase; //导入依赖的package包/类
@Override
public boolean isTableAvailable(final TableName tableName) throws IOException {
    final AtomicBoolean available = new AtomicBoolean(true);
    final AtomicInteger regionCount = new AtomicInteger(0);
    MetaScannerVisitor visitor = new MetaScannerVisitorBase() {
        @Override
        public boolean processRow(Result row) throws IOException {
            HRegionInfo info = MetaScanner.getHRegionInfo(row);
            if (info != null && !info.isSplitParent()) {
                if (tableName.equals(info.getTable())) {
                    ServerName server = HRegionInfo.getServerName(row);
                    if (server == null) {
                        available.set(false);
                        return false;
                    }
                    regionCount.incrementAndGet();
                } else if (tableName.compareTo(info.getTable()) < 0) {
                    // Return if we are done with the current table
                    return false;
                }
            }
            return true;
        }
    };
    MetaScanner.metaScan(this, visitor, tableName);
    return available.get() && (regionCount.get() > 0);
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:28,代码来源:ConnectionManager.java

示例13: getTableRegionForRow

import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase; //导入依赖的package包/类
/**
 * Return the region and current deployment for the region containing
 * the given row. If the region cannot be found, returns null. If it
 * is found, but not currently deployed, the second element of the pair
 * may be null.
 */
Pair<HRegionInfo, ServerName> getTableRegionForRow(
    final TableName tableName, final byte [] rowKey)
throws IOException {
  final AtomicReference<Pair<HRegionInfo, ServerName>> result =
    new AtomicReference<Pair<HRegionInfo, ServerName>>(null);

  MetaScannerVisitor visitor =
    new MetaScannerVisitorBase() {
      @Override
      public boolean processRow(Result data) throws IOException {
        if (data == null || data.size() <= 0) {
          return true;
        }
        Pair<HRegionInfo, ServerName> pair = HRegionInfo.getHRegionInfoAndServerName(data);
        if (pair == null) {
          return false;
        }
        if (!pair.getFirst().getTable().equals(tableName)) {
          return false;
        }
        result.set(pair);
        return true;
      }
  };

  MetaScanner.metaScan(conf, visitor, tableName, rowKey, 1);
  return result.get();
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:35,代码来源:HMaster.java

示例14: getRegion

import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase; //导入依赖的package包/类
/**
 * @param tableNameOrRegionName Name of a table or name of a region.
 * @param ct A {@link CatalogTracker} instance (caller of this method usually has one).
 * @return a pair of HRegionInfo and ServerName if <code>tableNameOrRegionName</code> is
 *  a verified region name (we call {@link  MetaReader#getRegion( CatalogTracker, byte[])}
 *  else null.
 * Throw an exception if <code>tableNameOrRegionName</code> is null.
 * @throws IOException
 */
Pair<HRegionInfo, ServerName> getRegion(final byte[] tableNameOrRegionName,
    final CatalogTracker ct) throws IOException {
  if (tableNameOrRegionName == null) {
    throw new IllegalArgumentException("Pass a table name or region name");
  }
  Pair<HRegionInfo, ServerName> pair = MetaReader.getRegion(ct, tableNameOrRegionName);
  if (pair == null) {
    final AtomicReference<Pair<HRegionInfo, ServerName>> result =
      new AtomicReference<Pair<HRegionInfo, ServerName>>(null);
    final String encodedName = Bytes.toString(tableNameOrRegionName);
    MetaScannerVisitor visitor = new MetaScannerVisitorBase() {
      @Override
      public boolean processRow(Result data) throws IOException {
        HRegionInfo info = HRegionInfo.getHRegionInfo(data);
        if (info == null) {
          LOG.warn("No serialized HRegionInfo in " + data);
          return true;
        }
        if (!encodedName.equals(info.getEncodedName())) return true;
        ServerName sn = HRegionInfo.getServerName(data);
        result.set(new Pair<HRegionInfo, ServerName>(info, sn));
        return false; // found the region, stop
      }
    };

    MetaScanner.metaScan(conf, connection, visitor, null);
    pair = result.get();
  }
  return pair;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:40,代码来源:HBaseAdmin.java

示例15: isTableAvailable

import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase; //导入依赖的package包/类
@Override
public boolean isTableAvailable(final TableName tableName) throws IOException {
  final AtomicBoolean available = new AtomicBoolean(true);
  final AtomicInteger regionCount = new AtomicInteger(0);
  MetaScannerVisitor visitor = new MetaScannerVisitorBase() {
    @Override
    public boolean processRow(Result row) throws IOException {
      HRegionInfo info = MetaScanner.getHRegionInfo(row);
      if (info != null && !info.isSplitParent()) {
        if (tableName.equals(info.getTable())) {
          ServerName server = HRegionInfo.getServerName(row);
          if (server == null) {
            available.set(false);
            return false;
          }
          regionCount.incrementAndGet();
        } else if (tableName.compareTo(info.getTable()) < 0) {
          // Return if we are done with the current table
          return false;
        }
      }
      return true;
    }
  };
  MetaScanner.metaScan(conf, this, visitor, tableName);
  return available.get() && (regionCount.get() > 0);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:28,代码来源:HConnectionManager.java


注:本文中的org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。