org.apache.hadoop.hbase.RegionException Java Examples

The following examples show how to use org.apache.hadoop.hbase.RegionException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Merge.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
/**
 * @param tableInfo
 * @return true: stop iteration, false: continue iteration
 * @throws Exception
 */
private boolean emptyInternal(TableInfo tableInfo) throws Exception {
    tableInfo.refresh();

    Set<HRegionInfo> mergedRegions = new HashSet<>();
    List<HRegionInfo> allTableRegions = new ArrayList<>(tableInfo.getRegionInfoSet());
    for (int i = 0; i < allTableRegions.size(); i++) {
        HRegionInfo region = allTableRegions.get(i);
        if (mergedRegions.contains(region)) continue;

        RegionLoadDelegator regionLoad = tableInfo.getRegionLoad(region);
        if (regionLoad == null) throw new IllegalStateException(Constant.MESSAGE_NEED_REFRESH);

        HRegionInfo targetRegion = getTargetRegion(tableInfo, allTableRegions, i, mergedRegions);
        if (mergedRegions.contains(targetRegion)) continue;

        if (regionLoad.getStorefileSizeMB() == 0 && regionLoad.getMemStoreSizeMB() == 0) {
            if (CommandAdapter.isReallyEmptyRegion(connection, tableInfo.getTableName(), region)) {
                try {
                    if (targetRegion != null) {
                        printMergeInfo(region, targetRegion);
                        mergedRegions.add(region);
                        mergedRegions.add(targetRegion);
                        CommandAdapter.mergeRegions(args, admin, region, targetRegion);
                        i++;
                    }
                } catch (RegionException e) {
                    throw new IllegalStateException(Constant.MESSAGE_NEED_REFRESH);
                }
            }
        }
    }

    System.out.println();
    return mergedRegions.size() <= 1;
}
 
Example #2
Source File: Merge.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
/**
 * @param tableInfo
 * @return true: stop iteration, false: continue iteration
 * @throws Exception
 */
private boolean emptyInternal(TableInfo tableInfo) throws Exception {
    tableInfo.refresh();

    Set<HRegionInfo> mergedRegions = new HashSet<>();
    List<HRegionInfo> allTableRegions = new ArrayList<>(tableInfo.getRegionInfoSet());
    for (int i = 0; i < allTableRegions.size(); i++) {
        HRegionInfo region = allTableRegions.get(i);
        if (mergedRegions.contains(region)) continue;

        RegionLoadDelegator regionLoad = tableInfo.getRegionLoad(region);
        if (regionLoad == null) throw new IllegalStateException(Constant.MESSAGE_NEED_REFRESH);

        HRegionInfo targetRegion = getTargetRegion(tableInfo, allTableRegions, i, mergedRegions);
        if (mergedRegions.contains(targetRegion)) continue;

        if (regionLoad.getStorefileSizeMB() == 0 && regionLoad.getMemStoreSizeMB() == 0) {
            if (CommandAdapter.isReallyEmptyRegion(connection, tableInfo.getTableName(), region)) {
                try {
                    if (targetRegion != null) {
                        printMergeInfo(region, targetRegion);
                        mergedRegions.add(region);
                        mergedRegions.add(targetRegion);
                        CommandAdapter.mergeRegions(args, admin, region, targetRegion);
                        i++;
                    }
                } catch (RegionException e) {
                    throw new IllegalStateException(Constant.MESSAGE_NEED_REFRESH);
                }
            }
        }
    }

    System.out.println();
    return mergedRegions.size() <= 1;
}
 
Example #3
Source File: Merge.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
/**
 * @param tableInfo
 * @return true: stop iteration, false: continue iteration
 * @throws Exception
 */
private boolean emptyInternal(TableInfo tableInfo) throws Exception {
    tableInfo.refresh();

    Set<HRegionInfo> mergedRegions = new HashSet<>();
    List<HRegionInfo> allTableRegions = new ArrayList<>(tableInfo.getRegionInfoSet());
    for (int i = 0; i < allTableRegions.size(); i++) {
        HRegionInfo region = allTableRegions.get(i);
        if (mergedRegions.contains(region)) continue;

        RegionLoadDelegator regionLoad = tableInfo.getRegionLoad(region);
        if (regionLoad == null) throw new IllegalStateException(Constant.MESSAGE_NEED_REFRESH);

        HRegionInfo targetRegion = getTargetRegion(tableInfo, allTableRegions, i, mergedRegions);
        if (mergedRegions.contains(targetRegion)) continue;

        if (regionLoad.getStorefileSizeMB() == 0 && regionLoad.getMemStoreSizeMB() == 0) {
            if (CommandAdapter.isReallyEmptyRegion(connection, tableInfo.getTableName(), region)) {
                try {
                    if (targetRegion != null) {
                        printMergeInfo(region, targetRegion);
                        mergedRegions.add(region);
                        mergedRegions.add(targetRegion);
                        CommandAdapter.mergeRegions(args, admin, region, targetRegion);
                        i++;
                    }
                } catch (RegionException e) {
                    throw new IllegalStateException(Constant.MESSAGE_NEED_REFRESH);
                }
            }
        }
    }

    System.out.println();
    return mergedRegions.size() <= 1;
}
 
Example #4
Source File: Merge.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
/**
 * @param tableInfo
 * @return true: stop iteration, false: continue iteration
 * @throws Exception
 */
private boolean emptyInternal(TableInfo tableInfo) throws Exception {
    tableInfo.refresh();

    Set<HRegionInfo> mergedRegions = new HashSet<>();
    List<HRegionInfo> allTableRegions = new ArrayList<>(tableInfo.getRegionInfoSet());
    for (int i = 0; i < allTableRegions.size(); i++) {
        HRegionInfo region = allTableRegions.get(i);
        if (mergedRegions.contains(region)) continue;

        RegionLoadDelegator regionLoad = tableInfo.getRegionLoad(region);
        if (regionLoad == null) throw new IllegalStateException(Constant.MESSAGE_NEED_REFRESH);

        HRegionInfo targetRegion = getTargetRegion(tableInfo, allTableRegions, i, mergedRegions);
        if (mergedRegions.contains(targetRegion)) continue;

        if (regionLoad.getStorefileSizeMB() == 0 && regionLoad.getMemStoreSizeMB() == 0) {
            if (CommandAdapter.isReallyEmptyRegion(connection, tableInfo.getTableName(), region)) {
                try {
                    if (targetRegion != null) {
                        printMergeInfo(region, targetRegion);
                        mergedRegions.add(region);
                        mergedRegions.add(targetRegion);
                        CommandAdapter.mergeRegions(args, admin, region, targetRegion);
                        i++;
                    }
                } catch (RegionException e) {
                    throw new IllegalStateException(Constant.MESSAGE_NEED_REFRESH);
                }
            }
        }
    }

    System.out.println();
    return mergedRegions.size() <= 1;
}
 
Example #5
Source File: Merge.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
/**
 * @param tableInfo
 * @return true: stop iteration, false: continue iteration
 * @throws Exception
 */
private boolean emptyInternal(TableInfo tableInfo) throws Exception {
    tableInfo.refresh();

    Set<HRegionInfo> mergedRegions = new HashSet<>();
    List<HRegionInfo> allTableRegions = new ArrayList<>(tableInfo.getRegionInfoSet());
    for (int i = 0; i < allTableRegions.size(); i++) {
        HRegionInfo region = allTableRegions.get(i);
        if (mergedRegions.contains(region)) continue;

        RegionLoadDelegator regionLoad = tableInfo.getRegionLoad(region);
        if (regionLoad == null) throw new IllegalStateException(Constant.MESSAGE_NEED_REFRESH);

        HRegionInfo targetRegion = getTargetRegion(tableInfo, allTableRegions, i, mergedRegions);
        if (mergedRegions.contains(targetRegion)) continue;

        if (regionLoad.getStorefileSizeMB() == 0 && regionLoad.getMemStoreSizeMB() == 0) {
            if (CommandAdapter.isReallyEmptyRegion(connection, tableInfo.getTableName(), region)) {
                try {
                    if (targetRegion != null) {
                        printMergeInfo(region, targetRegion);
                        mergedRegions.add(region);
                        mergedRegions.add(targetRegion);
                        CommandAdapter.mergeRegions(args, admin, region, targetRegion);
                        i++;
                    }
                } catch (RegionException e) {
                    throw new IllegalStateException(Constant.MESSAGE_NEED_REFRESH);
                }
            }
        }
    }

    System.out.println();
    return mergedRegions.size() <= 1;
}