/** * Sends a {@link Mutation} to the table. The mutations will be buffered and sent over the wire as * part of a batch. Currently only supports {@link Put} and {@link Delete} mutations. * @param mutation The data to send. */ default CompletableFuture<Void> mutate(Mutation mutation) { return Iterables.getOnlyElement(mutate(Collections.singletonList(mutation))); }
private void verifyFetchableViaAPI(Admin admin, ThrottleType type, long limit, TimeUnit tu) throws Exception { // Verify we can retrieve the new quota via the QuotaRetriever API try (QuotaRetriever quotaScanner = QuotaRetriever.open(admin.getConfiguration())) { assertRPCQuota(type, limit, tu, Iterables.getOnlyElement(quotaScanner)); } }
private void testZookeeperCanaryWithArgs(String[] args) throws Exception { Integer port = Iterables.getOnlyElement(testingUtility.getZkCluster().getClientPortList(), null); testingUtility.getConfiguration().set(HConstants.ZOOKEEPER_QUORUM, "localhost:" + port + "/hbase"); ExecutorService executor = new ScheduledThreadPoolExecutor(2); Canary.ZookeeperStdOutSink sink = spy(new Canary.ZookeeperStdOutSink()); Canary canary = new Canary(executor, sink); assertEquals(0, ToolRunner.run(testingUtility.getConfiguration(), canary, args)); String baseZnode = testingUtility.getConfiguration() .get(HConstants.ZOOKEEPER_ZNODE_PARENT, HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT); verify(sink, atLeastOnce()) .publishReadTiming(eq(baseZnode), eq("localhost:" + port), anyLong()); } }
@Test public void testRace() throws IOException, InterruptedException, ExecutionException { FSWALProvider p = new FSWALProvider(); WAL wal = p.getWAL(null); assertNotNull(GET_WALS_FUTURE); List<WAL> wals = GET_WALS_FUTURE.get(); assertSame(wal, Iterables.getOnlyElement(wals)); } }
@Test public void testIfWeHaveNewReferenceFilesButOldStoreFiles() throws Exception { // this tests that reference files that are new, but have older timestamps for the files // they reference still will get compacted. TableName table = TableName.valueOf("TestMajorCompactor"); TableDescriptor htd = UTILITY.createTableDescriptor(table, Bytes.toBytes(FAMILY)); RegionInfo hri = RegionInfoBuilder.newBuilder(htd.getTableName()).build(); HRegion region = HBaseTestingUtility.createRegionAndWAL(hri, rootRegionDir, UTILITY.getConfiguration(), htd); Configuration configuration = mock(Configuration.class); // the reference file timestamp is newer List<StoreFileInfo> storeFiles = mockStoreFiles(regionStoreDir, 4, 101); List<Path> paths = storeFiles.stream().map(StoreFileInfo::getPath).collect(Collectors.toList()); // the files that are referenced are older, thus we still compact. HRegionFileSystem fileSystem = mockFileSystem(region.getRegionInfo(), true, storeFiles, 50); MajorCompactionRequest majorCompactionRequest = spy(new MajorCompactionRequest(configuration, region.getRegionInfo(), Sets.newHashSet(FAMILY), 100)); doReturn(mock(Connection.class)).when(majorCompactionRequest).getConnection(eq(configuration)); doReturn(paths).when(majorCompactionRequest).getReferenceFilePaths(any(FileSystem.class), any(Path.class)); doReturn(fileSystem).when(majorCompactionRequest).getFileSystem(any(Connection.class)); Set<String> result = majorCompactionRequest.getStoresRequiringCompaction(Sets.newHashSet("a")); assertEquals(FAMILY, Iterables.getOnlyElement(result)); }
private void verifyRecordPresentInQuotaTable(ThrottleType type, long limit, TimeUnit tu) throws Exception { // Verify the RPC Quotas in the table try (Table quotaTable = TEST_UTIL.getConnection().getTable(QuotaTableUtil.QUOTA_TABLE_NAME); ResultScanner scanner = quotaTable.getScanner(new Scan())) { Result r = Iterables.getOnlyElement(scanner); CellScanner cells = r.cellScanner(); assertTrue("Expected to find a cell", cells.advance()); assertRPCQuota(type, limit, tu, cells.current()); } }
quotaSnapshots = snapshotNotifier.copySnapshots(); } else { Entry<TableName,SpaceQuotaSnapshot> entry = Iterables.getOnlyElement(quotaSnapshots.entrySet()); assertEquals(tn, entry.getKey()); final SpaceQuotaSnapshot snapshot = entry.getValue(); Iterables.getOnlyElement(quotaSnapshots.entrySet()); assertEquals(tn, entry.getKey()); final SpaceQuotaSnapshot snapshot = entry.getValue();
/** * Sends a {@link Mutation} to the table. The mutations will be buffered and sent over the wire as * part of a batch. Currently only supports {@link Put} and {@link Delete} mutations. * @param mutation The data to send. */ default CompletableFuture<Void> mutate(Mutation mutation) { return Iterables.getOnlyElement(mutate(Collections.singletonList(mutation))); }
ResultScanner scanner = quotaTable.getScanner(new Scan()); try { Result r = Iterables.getOnlyElement(scanner); CellScanner cells = r.cellScanner(); assertTrue("Expected to find a cell", cells.advance()); assertSpaceQuota(originalSizeLimit, violationPolicy, Iterables.getOnlyElement(quotaScanner)); } finally { quotaScanner.close(); ResultScanner scanner = quotaTable.getScanner(new Scan()); try { Result r = Iterables.getOnlyElement(scanner); CellScanner cells = r.cellScanner(); assertTrue("Expected to find a cell", cells.advance()); assertSpaceQuota(newSizeLimit, newViolationPolicy, Iterables.getOnlyElement(quotaScanner)); } finally { quotaScanner.close();
ResultScanner scanner = quotaTable.getScanner(new Scan()); try { Result r = Iterables.getOnlyElement(scanner); CellScanner cells = r.cellScanner(); assertTrue("Expected to find a cell", cells.advance()); assertSpaceQuota(sizeLimit, violationPolicy, Iterables.getOnlyElement(scanner)); } finally { scanner.close();
HRegion region = Iterables.getOnlyElement(TEST_UTIL.getHBaseCluster().getRegions(tn)); long numFiles = getNumHFilesForRegion(region); assertEquals(numBatches, numFiles);
SyncReplicationState.STANDBY); RegionInfo region = Iterables.getOnlyElement(UTIL2.getAdmin().getRegions(TABLE_NAME)); HRegionServer target = UTIL2.getOtherRegionServer(UTIL2.getRSForFirstRegionInTable(TABLE_NAME)); UTIL2.getAdmin().move(region.getEncodedNameAsBytes(),
Region region = Iterables.getOnlyElement(TEST_UTIL.getHBaseCluster().getRegions(tn)); List<? extends Store> stores = region.getStores(); long summer = 0;
static <K extends Enum<K>, V> ImmutableMap<K, V> asImmutable(EnumMap<K, V> map) { switch (map.size()) { case 0: return ImmutableMap.of(); case 1: Entry<K, V> entry = Iterables.getOnlyElement(map.entrySet()); return ImmutableMap.of(entry.getKey(), entry.getValue()); default: return new ImmutableEnumMap<K, V>(map); } }
@SuppressWarnings("rawtypes") // necessary to compile against Java 8 static ImmutableSet asImmutable(EnumSet set) { switch (set.size()) { case 0: return ImmutableSet.of(); case 1: return ImmutableSet.of(Iterables.getOnlyElement(set)); default: return new ImmutableEnumSet(set); } }
/** * Returns a newly-created immutable table. * * @throws IllegalArgumentException if duplicate key pairs were added */ public ImmutableTable<R, C, V> build() { int size = cells.size(); switch (size) { case 0: return of(); case 1: return new SingletonImmutableTable<R, C, V>(Iterables.getOnlyElement(cells)); default: return RegularImmutableTable.forCells(cells, rowComparator, columnComparator); } } }
private void verifyFetchableViaAPI(Admin admin, ThrottleType type, long limit, TimeUnit tu) throws Exception { // Verify we can retrieve the new quota via the QuotaRetriever API try (QuotaRetriever quotaScanner = QuotaRetriever.open(admin.getConfiguration())) { assertRPCQuota(type, limit, tu, Iterables.getOnlyElement(quotaScanner)); } }
private void testZookeeperCanaryWithArgs(String[] args) throws Exception { Integer port = Iterables.getOnlyElement(testingUtility.getZkCluster().getClientPortList(), null); testingUtility.getConfiguration().set(HConstants.ZOOKEEPER_QUORUM, "localhost:" + port + "/hbase"); ExecutorService executor = new ScheduledThreadPoolExecutor(2); Canary.ZookeeperStdOutSink sink = spy(new Canary.ZookeeperStdOutSink()); Canary canary = new Canary(executor, sink); assertEquals(0, ToolRunner.run(testingUtility.getConfiguration(), canary, args)); String baseZnode = testingUtility.getConfiguration() .get(HConstants.ZOOKEEPER_ZNODE_PARENT, HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT); verify(sink, atLeastOnce()) .publishReadTiming(eq(baseZnode), eq("localhost:" + port), anyLong()); } }
@Test public void testRace() throws IOException, InterruptedException, ExecutionException { FSWALProvider p = new FSWALProvider(); WAL wal = p.getWAL(null); assertNotNull(GET_WALS_FUTURE); List<WAL> wals = GET_WALS_FUTURE.get(); assertSame(wal, Iterables.getOnlyElement(wals)); } }
private void verifyRecordPresentInQuotaTable(ThrottleType type, long limit, TimeUnit tu) throws Exception { // Verify the RPC Quotas in the table try (Table quotaTable = TEST_UTIL.getConnection().getTable(QuotaTableUtil.QUOTA_TABLE_NAME); ResultScanner scanner = quotaTable.getScanner(new Scan())) { Result r = Iterables.getOnlyElement(scanner); CellScanner cells = r.cellScanner(); assertTrue("Expected to find a cell", cells.advance()); assertRPCQuota(type, limit, tu, cells.current()); } }