Java Code Examples for org.apache.hadoop.hbase.HRegionInfo#getRegionName()

The following examples show how to use org.apache.hadoop.hbase.HRegionInfo#getRegionName() . 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: THLog.java    From hbase-secondary-index with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Write a transactional state to the log for a commit request.
 * 
 * @param regionInfo
 * @param update
 * @param transactionId
 * @throws IOException
 */
private void appendCommitRequest(final HRegionInfo regionInfo,
		final long now, final TransactionState transactionState)
		throws IOException {

	@SuppressWarnings("deprecation")
	THLogKey key = new THLogKey(regionInfo.getRegionName(), regionInfo
			.getTableDesc().getName(), -1, now,
			THLogKey.TrxOp.COMMIT_REQUEST,
			transactionState.getTransactionId());

	WALEdit e = new WALEdit();

	for (WriteAction write : transactionState.getWriteOrdering()) {
		for (KeyValue value : write.getKeyValues()) {
			e.add(value);
		}
	}

	super.append(regionInfo, key, e, null, false);

}
 
Example 2
Source File: MC.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
private void filterWithDataLocality(Set<byte[]> targets,
    Map<byte[], HRegionInfo> regionMap) throws IOException {
    long startTimestamp = System.currentTimeMillis();
    Util.printVerboseMessage(args, Util.getMethodName() + " - start");

    final Double dataLocalityThreshold;
    if (args.has(Args.OPTION_LOCALITY_THRESHOLD)) {
        dataLocalityThreshold = (Double) args.valueOf(Args.OPTION_LOCALITY_THRESHOLD);
        if (dataLocalityThreshold < 1 || dataLocalityThreshold > 100)
            throw new IllegalArgumentException("Invalid data locality");
    } else {
        dataLocalityThreshold = null;
    }

    RegionLoadAdapter regionLoadAdapter = new RegionLoadAdapter(admin, regionMap, args);
    for (HRegionInfo regionInfo : regionMap.values()) {
        RegionLoadDelegator regionLoad = regionLoadAdapter.get(regionInfo);
        if (regionLoad == null) continue;
        try {
            byte[] regionName = regionInfo.getRegionName();
            regionSizeMap.put(regionName, regionLoad.getStorefileSizeMB());
            if (dataLocalityThreshold == null) {
                targets.add(regionName);
            } else {
                float dataLocality = regionLoad.getDataLocality();
                regionLocalityMap.put(regionName, dataLocality);
                if (dataLocality * 100 < dataLocalityThreshold) targets.add(regionName);
            }
        } catch (IllegalStateException e) {
            if (e.getMessage().contains("not implemented")) {
                throw new IllegalStateException("Option " + Args.OPTION_LOCALITY_THRESHOLD
                    + " is not supported in this HBase version.");
            } else {
                throw e;
            }
        }
    }

    Util.printVerboseMessage(args, Util.getMethodName() + " - end", startTimestamp);
}
 
Example 3
Source File: MC.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
private void filterWithDataLocality(Set<byte[]> targets,
    Map<byte[], HRegionInfo> regionMap) throws IOException {
    long startTimestamp = System.currentTimeMillis();
    Util.printVerboseMessage(args, Util.getMethodName() + " - start");

    final Double dataLocalityThreshold;
    if (args.has(Args.OPTION_LOCALITY_THRESHOLD)) {
        dataLocalityThreshold = (Double) args.valueOf(Args.OPTION_LOCALITY_THRESHOLD);
        if (dataLocalityThreshold < 1 || dataLocalityThreshold > 100)
            throw new IllegalArgumentException("Invalid data locality");
    } else {
        dataLocalityThreshold = null;
    }

    RegionLoadAdapter regionLoadAdapter = new RegionLoadAdapter(admin, regionMap, args);
    for (HRegionInfo regionInfo : regionMap.values()) {
        RegionLoadDelegator regionLoad = regionLoadAdapter.get(regionInfo);
        if (regionLoad == null) continue;
        try {
            byte[] regionName = regionInfo.getRegionName();
            regionSizeMap.put(regionName, regionLoad.getStorefileSizeMB());
            if (dataLocalityThreshold == null) {
                targets.add(regionName);
            } else {
                float dataLocality = regionLoad.getDataLocality();
                regionLocalityMap.put(regionName, dataLocality);
                if (dataLocality * 100 < dataLocalityThreshold) targets.add(regionName);
            }
        } catch (IllegalStateException e) {
            if (e.getMessage().contains("not implemented")) {
                throw new IllegalStateException("Option " + Args.OPTION_LOCALITY_THRESHOLD
                    + " is not supported in this HBase version.");
            } else {
                throw e;
            }
        }
    }

    Util.printVerboseMessage(args, Util.getMethodName() + " - end", startTimestamp);
}
 
Example 4
Source File: MC.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
private void filterWithDataLocality(Set<byte[]> targets,
    Map<byte[], HRegionInfo> regionMap) throws IOException {
    long startTimestamp = System.currentTimeMillis();
    Util.printVerboseMessage(args, Util.getMethodName() + " - start");

    final Double dataLocalityThreshold;
    if (args.has(Args.OPTION_LOCALITY_THRESHOLD)) {
        dataLocalityThreshold = (Double) args.valueOf(Args.OPTION_LOCALITY_THRESHOLD);
        if (dataLocalityThreshold < 1 || dataLocalityThreshold > 100)
            throw new IllegalArgumentException("Invalid data locality");
    } else {
        dataLocalityThreshold = null;
    }

    RegionLoadAdapter regionLoadAdapter = new RegionLoadAdapter(admin, regionMap, args);
    for (HRegionInfo regionInfo : regionMap.values()) {
        RegionLoadDelegator regionLoad = regionLoadAdapter.get(regionInfo);
        if (regionLoad == null) continue;
        try {
            byte[] regionName = regionInfo.getRegionName();
            regionSizeMap.put(regionName, regionLoad.getStorefileSizeMB());
            if (dataLocalityThreshold == null) {
                targets.add(regionName);
            } else {
                float dataLocality = regionLoad.getDataLocality();
                regionLocalityMap.put(regionName, dataLocality);
                if (dataLocality * 100 < dataLocalityThreshold) targets.add(regionName);
            }
        } catch (IllegalStateException e) {
            if (e.getMessage().contains("not implemented")) {
                throw new IllegalStateException("Option " + Args.OPTION_LOCALITY_THRESHOLD
                    + " is not supported in this HBase version.");
            } else {
                throw e;
            }
        }
    }

    Util.printVerboseMessage(args, Util.getMethodName() + " - end", startTimestamp);
}
 
Example 5
Source File: MC.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
private void filterWithDataLocality(Set<byte[]> targets,
    Map<byte[], HRegionInfo> regionMap) throws IOException {
    long startTimestamp = System.currentTimeMillis();
    Util.printVerboseMessage(args, Util.getMethodName() + " - start");

    final Double dataLocalityThreshold;
    if (args.has(Args.OPTION_LOCALITY_THRESHOLD)) {
        dataLocalityThreshold = (Double) args.valueOf(Args.OPTION_LOCALITY_THRESHOLD);
        if (dataLocalityThreshold < 1 || dataLocalityThreshold > 100)
            throw new IllegalArgumentException("Invalid data locality");
    } else {
        dataLocalityThreshold = null;
    }

    RegionLoadAdapter regionLoadAdapter = new RegionLoadAdapter(admin, regionMap, args);
    for (HRegionInfo regionInfo : regionMap.values()) {
        RegionLoadDelegator regionLoad = regionLoadAdapter.get(regionInfo);
        if (regionLoad == null) continue;
        try {
            byte[] regionName = regionInfo.getRegionName();
            regionSizeMap.put(regionName, regionLoad.getStorefileSizeMB());
            if (dataLocalityThreshold == null) {
                targets.add(regionName);
            } else {
                float dataLocality = regionLoad.getDataLocality();
                regionLocalityMap.put(regionName, dataLocality);
                if (dataLocality * 100 < dataLocalityThreshold) targets.add(regionName);
            }
        } catch (IllegalStateException e) {
            if (e.getMessage().contains("not implemented")) {
                throw new IllegalStateException("Option " + Args.OPTION_LOCALITY_THRESHOLD
                    + " is not supported in this HBase version.");
            } else {
                throw e;
            }
        }
    }

    Util.printVerboseMessage(args, Util.getMethodName() + " - end", startTimestamp);
}
 
Example 6
Source File: MC.java    From hbase-tools with Apache License 2.0 5 votes vote down vote up
private void filterWithDataLocality(Set<byte[]> targets,
    Map<byte[], HRegionInfo> regionMap) throws IOException {
    long startTimestamp = System.currentTimeMillis();
    Util.printVerboseMessage(args, Util.getMethodName() + " - start");

    final Double dataLocalityThreshold;
    if (args.has(Args.OPTION_LOCALITY_THRESHOLD)) {
        dataLocalityThreshold = (Double) args.valueOf(Args.OPTION_LOCALITY_THRESHOLD);
        if (dataLocalityThreshold < 1 || dataLocalityThreshold > 100)
            throw new IllegalArgumentException("Invalid data locality");
    } else {
        dataLocalityThreshold = null;
    }

    RegionLoadAdapter regionLoadAdapter = new RegionLoadAdapter(admin, regionMap, args);
    for (HRegionInfo regionInfo : regionMap.values()) {
        RegionLoadDelegator regionLoad = regionLoadAdapter.get(regionInfo);
        if (regionLoad == null) continue;
        try {
            byte[] regionName = regionInfo.getRegionName();
            regionSizeMap.put(regionName, regionLoad.getStorefileSizeMB());
            if (dataLocalityThreshold == null) {
                targets.add(regionName);
            } else {
                float dataLocality = regionLoad.getDataLocality();
                regionLocalityMap.put(regionName, dataLocality);
                if (dataLocality * 100 < dataLocalityThreshold) targets.add(regionName);
            }
        } catch (IllegalStateException e) {
            if (e.getMessage().contains("not implemented")) {
                throw new IllegalStateException("Option " + Args.OPTION_LOCALITY_THRESHOLD
                    + " is not supported in this HBase version.");
            } else {
                throw e;
            }
        }
    }

    Util.printVerboseMessage(args, Util.getMethodName() + " - end", startTimestamp);
}
 
Example 7
Source File: THLog.java    From hbase-secondary-index with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Write a general transaction op to the log. This covers: start, commit,
 * and abort.
 * 
 * @param regionInfo
 * @param now
 * @param txOp
 * @param transactionId
 * @throws IOException
 */
private void append(final HRegionInfo regionInfo, final long now,
		final THLogKey.TrxOp txOp, final long transactionId)
		throws IOException {
	@SuppressWarnings("deprecation")
	THLogKey key = new THLogKey(regionInfo.getRegionName(), regionInfo
			.getTableDesc().getName(), -1, now, txOp, transactionId);
	WALEdit e = new WALEdit();
	e.add(new KeyValue(new byte[0], 0, 0)); // Empty KeyValue
	super.append(regionInfo, key, e, null, false);
}