@Override public void handleSplit(HbckInfo r1, HbckInfo r2) throws IOException{ byte[] key = r1.getStartKey(); // dup start key errors.reportError(ERROR_CODE.DUPE_ENDKEYS, "Multiple regions have the same regionID: " + Bytes.toStringBinary(key), getTableInfo(), r1); errors.reportError(ERROR_CODE.DUPE_ENDKEYS, "Multiple regions have the same regionID: " + Bytes.toStringBinary(key), getTableInfo(), r2); }
protected Pool<V> createPool() { switch (poolType) { case Reusable: return new ReusablePool<>(poolMaxSize); case RoundRobin: return new RoundRobinPool<>(poolMaxSize); case ThreadLocal: return new ThreadLocalPool<>(); } return null; }
private static byte[][] getSplits(int numRegions) { RegionSplitter.UniformSplit split = new RegionSplitter.UniformSplit(); split.setFirstRow(Bytes.toBytes(0L)); split.setLastRow(Bytes.toBytes(Long.MAX_VALUE)); return split.split(numRegions); }
public void testStartsWith() { assertTrue(Bytes.startsWith(Bytes.toBytes("hello"), Bytes.toBytes("h"))); assertTrue(Bytes.startsWith(Bytes.toBytes("hello"), Bytes.toBytes(""))); assertTrue(Bytes.startsWith(Bytes.toBytes("hello"), Bytes.toBytes("hello"))); assertFalse(Bytes.startsWith(Bytes.toBytes("hello"), Bytes.toBytes("helloworld"))); assertFalse(Bytes.startsWith(Bytes.toBytes(""), Bytes.toBytes("hello"))); }
/** * Creates and returns a Table instance from a given table name. * * @param tableName * name of table * @return Table object * @throws IOException if getting the table fails */ protected Table getTable(final byte[] tableName) throws IOException { String table = Bytes.toString(tableName); return connectionCache.getTable(table); }
public void testAdd () throws Exception { byte[] a = {0,0,0,0,0,0,0,0,0,0}; byte[] b = {1,1,1,1,1,1,1,1,1,1,1}; byte[] c = {2,2,2,2,2,2,2,2,2,2,2,2}; byte[] d = {3,3,3,3,3,3,3,3,3,3,3,3,3}; byte[] result1 = Bytes.add (a, b, c); byte[] result2 = Bytes.add (new byte[][] {a, b, c}); assertEquals(0, Bytes.compareTo(result1, result2)); byte[] result4 = Bytes.add (result1, d); byte[] result5 = Bytes.add (new byte[][] {result1, d}); assertEquals(0, Bytes.compareTo(result1, result2)); }
@Override public void handleHoleInRegionChain(byte[] holeStart, byte[] holeStop) throws IOException{ errors.reportError( ERROR_CODE.HOLE_IN_REGION_CHAIN, "There is a hole in the region chain between " + Bytes.toStringBinary(holeStart) + " and " + Bytes.toStringBinary(holeStop) + ". You need to create a new .regioninfo and region " + "dir in hdfs to plug the hole."); } }
/** * Get an exponential backoff retry counter. The base unit is 100 milliseconds, and the max * backoff time is 30 seconds. */ public static RetryCounter getRetryCounter() { return new RetryCounterFactory( new RetryCounter.RetryConfig().setBackoffPolicy(new RetryCounter.ExponentialBackoffPolicy()) .setSleepInterval(100).setMaxSleepTime(30000).setMaxAttempts(Integer.MAX_VALUE) .setTimeUnit(TimeUnit.MILLISECONDS).setJitter(0.01f)).create(); } }
/** * Get the full path to the archive directory on the configured * {@link org.apache.hadoop.hbase.master.MasterFileSystem} * @param conf to look for archive directory name and root directory. Cannot be null. Notes for * testing: requires a FileSystem root directory to be specified. * @return the full {@link Path} to the archive directory, as defined by the configuration * @throws IOException if an unexpected error occurs */ public static Path getArchivePath(Configuration conf) throws IOException { return getArchivePath(FSUtils.getRootDir(conf)); }
/** * Returns the latest table descriptor for the given table directly from the file system * if it exists, bypassing the local cache. * Returns null if it's not found. */ public static TableDescriptor getTableDescriptorFromFs(FileSystem fs, Path hbaseRootDir, TableName tableName) throws IOException { Path tableDir = FSUtils.getTableDir(hbaseRootDir, tableName); return getTableDescriptorFromFs(fs, tableDir); }
/** * Encode a null value. * @param dst The destination to which encoded digits are written. * @param ord The {@link Order} to respect while encoding {@code val}. * @return the number of bytes written. */ public static int encodeNull(PositionedByteRange dst, Order ord) { dst.put(ord.apply(NULL)); return 1; }
@Override public ByteRange set(int capacity) { if (super.bytes != null) { throw new ReadOnlyByteRangeException(); } return super.set(capacity); }
@Override public void handleOverlapInRegionChain(HbckInfo hi1, HbckInfo hi2) throws IOException{ errors.reportError(ERROR_CODE.OVERLAP_IN_REGION_CHAIN, "There is an overlap in the region chain.", getTableInfo(), hi1, hi2); }
public static boolean contains(Cell cell, ByteBuff bloomBuf, int bloomOffset, int bloomSize, Hash hash, int hashCount, BloomType type) { HashKey<Cell> hashKey = type == BloomType.ROWCOL ? new RowColBloomHashKey(cell) : new RowBloomHashKey(cell); return contains(bloomBuf, bloomOffset, bloomSize, hash, hashCount, hashKey); }
/** * Bloom information from the cell is retrieved * @param cell * @throws IOException */ public void writeBloom(Cell cell) throws IOException { // only add to the bloom filter on a new, unique key if (isNewKey(cell)) { sanityCheck(cell); bloomFilterWriter.append(cell); } }
private static byte[][] getSplits(int numRegions) { RegionSplitter.UniformSplit split = new RegionSplitter.UniformSplit(); split.setFirstRow(Bytes.toBytes(0L)); split.setLastRow(Bytes.toBytes(Long.MAX_VALUE)); return split.split(numRegions); }
@Override public void handleDuplicateStartKeys(HbckInfo r1, HbckInfo r2) throws IOException{ byte[] key = r1.getStartKey(); // dup start key errors.reportError(ERROR_CODE.DUPE_STARTKEYS, "Multiple regions have the same startkey: " + Bytes.toStringBinary(key), getTableInfo(), r1); errors.reportError(ERROR_CODE.DUPE_STARTKEYS, "Multiple regions have the same startkey: " + Bytes.toStringBinary(key), getTableInfo(), r2); }
private byte[][] getSplits(int numRegions) { RegionSplitter.UniformSplit split = new RegionSplitter.UniformSplit(); split.setFirstRow(Bytes.toBytes(0L)); split.setLastRow(Bytes.toBytes(Long.MAX_VALUE)); return split.split(numRegions); }