Search in sources :

Example 66 with VisibleForTesting

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project hbase by apache.

the class HRegionLocator method listRegionLocations.

@VisibleForTesting
List<RegionLocations> listRegionLocations() throws IOException {
    final List<RegionLocations> regions = new ArrayList<>();
    MetaTableAccessor.Visitor visitor = new MetaTableAccessor.TableVisitorBase(tableName) {

        @Override
        public boolean visitInternal(Result result) throws IOException {
            RegionLocations locations = MetaTableAccessor.getRegionLocations(result);
            if (locations == null)
                return true;
            regions.add(locations);
            return true;
        }
    };
    MetaTableAccessor.scanMetaForTableRegions(connection, visitor, tableName);
    return regions;
}
Also used : RegionLocations(org.apache.hadoop.hbase.RegionLocations) ArrayList(java.util.ArrayList) MetaTableAccessor(org.apache.hadoop.hbase.MetaTableAccessor) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 67 with VisibleForTesting

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project hbase by apache.

the class HBaseAdmin method split.

@VisibleForTesting
public void split(final ServerName sn, final HRegionInfo hri, byte[] splitPoint) throws IOException {
    if (hri.getStartKey() != null && splitPoint != null && Bytes.compareTo(hri.getStartKey(), splitPoint) == 0) {
        throw new IOException("should not give a splitkey which equals to startkey!");
    }
    // TODO: There is no timeout on this controller. Set one!
    HBaseRpcController controller = rpcControllerFactory.newController();
    controller.setPriority(hri.getTable());
    // TODO: this does not do retries, it should. Set priority and timeout in controller
    AdminService.BlockingInterface admin = this.connection.getAdmin(sn);
    ProtobufUtil.split(controller, admin, hri, splitPoint);
}
Also used : HBaseRpcController(org.apache.hadoop.hbase.ipc.HBaseRpcController) AdminService(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) TimeoutIOException(org.apache.hadoop.hbase.exceptions.TimeoutIOException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 68 with VisibleForTesting

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project hbase by apache.

the class HFileOutputFormat2 method configureBlockSize.

/**
   * Serialize column family to block size map to configuration.
   * Invoked while configuring the MR job for incremental load.
   * @param tableDescriptor to read the properties from
   * @param conf to persist serialized values into
   *
   * @throws IOException
   *           on failure to read column family descriptors
   */
@VisibleForTesting
static void configureBlockSize(HTableDescriptor tableDescriptor, Configuration conf) throws UnsupportedEncodingException {
    StringBuilder blockSizeConfigValue = new StringBuilder();
    if (tableDescriptor == null) {
        // could happen with mock table instance
        return;
    }
    Collection<HColumnDescriptor> families = tableDescriptor.getFamilies();
    int i = 0;
    for (HColumnDescriptor familyDescriptor : families) {
        if (i++ > 0) {
            blockSizeConfigValue.append('&');
        }
        blockSizeConfigValue.append(URLEncoder.encode(familyDescriptor.getNameAsString(), "UTF-8"));
        blockSizeConfigValue.append('=');
        blockSizeConfigValue.append(URLEncoder.encode(String.valueOf(familyDescriptor.getBlocksize()), "UTF-8"));
    }
    // Get rid of the last ampersand
    conf.set(BLOCK_SIZE_FAMILIES_CONF_KEY, blockSizeConfigValue.toString());
}
Also used : HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 69 with VisibleForTesting

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project hbase by apache.

the class HFileOutputFormat2 method configureCompression.

/**
   * Serialize column family to compression algorithm map to configuration.
   * Invoked while configuring the MR job for incremental load.
   *
   * @param tableDescriptor to read the properties from
   * @param conf to persist serialized values into
   * @throws IOException
   *           on failure to read column family descriptors
   */
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE")
@VisibleForTesting
static void configureCompression(Configuration conf, HTableDescriptor tableDescriptor) throws UnsupportedEncodingException {
    StringBuilder compressionConfigValue = new StringBuilder();
    if (tableDescriptor == null) {
        // could happen with mock table instance
        return;
    }
    Collection<HColumnDescriptor> families = tableDescriptor.getFamilies();
    int i = 0;
    for (HColumnDescriptor familyDescriptor : families) {
        if (i++ > 0) {
            compressionConfigValue.append('&');
        }
        compressionConfigValue.append(URLEncoder.encode(familyDescriptor.getNameAsString(), "UTF-8"));
        compressionConfigValue.append('=');
        compressionConfigValue.append(URLEncoder.encode(familyDescriptor.getCompressionType().getName(), "UTF-8"));
    }
    // Get rid of the last ampersand
    conf.set(COMPRESSION_FAMILIES_CONF_KEY, compressionConfigValue.toString());
}
Also used : HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 70 with VisibleForTesting

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.annotations.VisibleForTesting in project hbase by apache.

the class HFileOutputFormat2 method configureBloomType.

/**
   * Serialize column family to bloom type map to configuration.
   * Invoked while configuring the MR job for incremental load.
   * @param tableDescriptor to read the properties from
   * @param conf to persist serialized values into
   *
   * @throws IOException
   *           on failure to read column family descriptors
   */
@VisibleForTesting
static void configureBloomType(HTableDescriptor tableDescriptor, Configuration conf) throws UnsupportedEncodingException {
    if (tableDescriptor == null) {
        // could happen with mock table instance
        return;
    }
    StringBuilder bloomTypeConfigValue = new StringBuilder();
    Collection<HColumnDescriptor> families = tableDescriptor.getFamilies();
    int i = 0;
    for (HColumnDescriptor familyDescriptor : families) {
        if (i++ > 0) {
            bloomTypeConfigValue.append('&');
        }
        bloomTypeConfigValue.append(URLEncoder.encode(familyDescriptor.getNameAsString(), "UTF-8"));
        bloomTypeConfigValue.append('=');
        String bloomType = familyDescriptor.getBloomFilterType().toString();
        if (bloomType == null) {
            bloomType = HColumnDescriptor.DEFAULT_BLOOMFILTER;
        }
        bloomTypeConfigValue.append(URLEncoder.encode(bloomType, "UTF-8"));
    }
    conf.set(BLOOM_TYPE_FAMILIES_CONF_KEY, bloomTypeConfigValue.toString());
}
Also used : HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1955 IOException (java.io.IOException)284 ArrayList (java.util.ArrayList)214 Map (java.util.Map)156 HashMap (java.util.HashMap)147 List (java.util.List)113 File (java.io.File)94 ImmutableMap (com.google.common.collect.ImmutableMap)72 HashSet (java.util.HashSet)67 Path (org.apache.hadoop.fs.Path)63 ImmutableList (com.google.common.collect.ImmutableList)60 Path (java.nio.file.Path)60 Set (java.util.Set)52 Matcher (java.util.regex.Matcher)46 Collectors (java.util.stream.Collectors)46 Collection (java.util.Collection)39 Optional (java.util.Optional)38 NotNull (org.jetbrains.annotations.NotNull)37 ImmutableSet (com.google.common.collect.ImmutableSet)34 TreeMap (java.util.TreeMap)34