@Override public void mutateRow(ByteBuffer table, TRowMutations rowMutations) throws TIOError, TException { checkReadOnlyMode(); Table htable = getTable(table); try { htable.mutateRow(rowMutationsFromThrift(rowMutations)); } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }
/** * Reset the split parent region info in meta table */ private void resetSplitParent(HbckInfo hi) throws IOException { RowMutations mutations = new RowMutations(hi.metaEntry.getRegionName()); Delete d = new Delete(hi.metaEntry.getRegionName()); d.addColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER); d.addColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER); mutations.add(d); RegionInfo hri = RegionInfoBuilder.newBuilder(hi.metaEntry) .setOffline(false) .setSplit(false) .build(); Put p = MetaTableAccessor.makePutFromRegionInfo(hri, EnvironmentEdgeManager.currentTime()); mutations.add(p); meta.mutateRow(mutations); LOG.info("Reset split parent " + hi.metaEntry.getRegionNameAsString() + " in META" ); }
@Test public void testRowMutationsWithPreBatchMutate() throws Exception { final TableName tableName = TableName.valueOf(name.getMethodName()); testPreBatchMutate(tableName, () -> { try { RowMutations rm = new RowMutations(ROW, 1); Table t = TEST_UTIL.getConnection().getTable(tableName); Put put = new Put(ROW); put.addColumn(FAMILY, QUALIFIER, VALUE); rm.add(put); t.mutateRow(rm); } catch (IOException ex) { throw new RuntimeException(ex); } }); }
@Override public void mutateRow(RowMutations rm) throws IOException { delegate.mutateRow(rm); }
p.addColumn(FAMILY, QUALIFIERS[0], VALUE); arm.add(p); t.mutateRow(arm); arm.add(d); t.mutateRow(arm); r = t.get(g); assertEquals(0, Bytes.compareTo(VALUE, r.getValue(FAMILY, QUALIFIERS[1]))); p.addColumn(new byte[]{'b', 'o', 'g', 'u', 's'}, QUALIFIERS[0], VALUE); arm.add(p); t.mutateRow(arm); fail("Expected NoSuchColumnFamilyException"); } catch(RetriesExhaustedWithDetailsException e) {
Arrays.asList(new Put(Bytes.toBytes("row")).addColumn(CF, CQ, Bytes.toBytes("row")), new Put(Bytes.toBytes("row1")).addColumn(CF, CQ, Bytes.toBytes("row1"))))); assertDisallow(table, t -> t.mutateRow(new RowMutations(Bytes.toBytes("row")) .add((Mutation) new Put(Bytes.toBytes("row")).addColumn(CF, CQ, Bytes.toBytes("row")))));
p1.setDurability(Durability.SYNC_WAL); rm.add(p1); hTable.mutateRow(rm);
@Test public void testFlushedFileWithVisibilityTags() throws Exception { final byte[] qual2 = Bytes.toBytes("qual2"); TableName tableName = TableName.valueOf(TEST_NAME.getMethodName()); HTableDescriptor desc = new HTableDescriptor(tableName); HColumnDescriptor col = new HColumnDescriptor(fam); desc.addFamily(col); TEST_UTIL.getAdmin().createTable(desc); try (Table table = TEST_UTIL.getConnection().getTable(tableName)) { Put p1 = new Put(row1); p1.addColumn(fam, qual, value); p1.setCellVisibility(new CellVisibility(CONFIDENTIAL)); Put p2 = new Put(row1); p2.addColumn(fam, qual2, value); p2.setCellVisibility(new CellVisibility(SECRET)); RowMutations rm = new RowMutations(row1); rm.add(p1); rm.add(p2); table.mutateRow(rm); } TEST_UTIL.getAdmin().flush(tableName); List<HRegion> regions = TEST_UTIL.getHBaseCluster().getRegions(tableName); HStore store = regions.get(0).getStore(fam); Collection<HStoreFile> storefiles = store.getStorefiles(); assertTrue(storefiles.size() > 0); for (HStoreFile storeFile : storefiles) { assertTrue(storeFile.getReader().getHFileReader().getFileContext().isIncludesTags()); } }
@Test public void testMutateRowStats() throws IOException { Configuration conf = UTIL.getConfiguration(); ClusterConnection conn = (ClusterConnection) ConnectionFactory.createConnection(conf); Table table = conn.getTable(tableName); HRegionServer rs = UTIL.getHBaseCluster().getRegionServer(0); Region region = rs.getRegions(tableName).get(0); RowMutations mutations = new RowMutations(Bytes.toBytes("row")); Put p = new Put(Bytes.toBytes("row")); p.addColumn(family, qualifier, Bytes.toBytes("value2")); mutations.add(p); table.mutateRow(mutations); ServerStatisticTracker stats = conn.getStatisticsTracker(); assertNotNull( "No stats configured for the client!", stats); // get the names so we can query the stats ServerName server = rs.getServerName(); byte[] regionName = region.getRegionInfo().getRegionName(); // check to see we found some load on the memstore ServerStatistics serverStats = stats.getServerStatsForTesting(server); ServerStatistics.RegionStatistics regionStats = serverStats.getStatsForRegion(regionName); assertNotNull(regionStats); assertTrue(regionStats.getMemStoreLoadPercent() > 0); } }
@Test public void testMutateRow() throws Exception { final byte[] qual2 = Bytes.toBytes("qual2"); TableName tableName = TableName.valueOf(TEST_NAME.getMethodName()); HTableDescriptor desc = new HTableDescriptor(tableName); HColumnDescriptor col = new HColumnDescriptor(fam); desc.addFamily(col); TEST_UTIL.getAdmin().createTable(desc); try (Table table = TEST_UTIL.getConnection().getTable(tableName)){ Put p1 = new Put(row1); p1.addColumn(fam, qual, value); p1.setCellVisibility(new CellVisibility(CONFIDENTIAL)); Put p2 = new Put(row1); p2.addColumn(fam, qual2, value); p2.setCellVisibility(new CellVisibility(SECRET)); RowMutations rm = new RowMutations(row1); rm.add(p1); rm.add(p2); table.mutateRow(rm); Get get = new Get(row1); get.setAuthorizations(new Authorizations(CONFIDENTIAL)); Result result = table.get(get); assertTrue(result.containsColumn(fam, qual)); assertFalse(result.containsColumn(fam, qual2)); get.setAuthorizations(new Authorizations(SECRET)); result = table.get(get); assertFalse(result.containsColumn(fam, qual)); assertTrue(result.containsColumn(fam, qual2)); } }
@Test public void testRowMutation() throws IOException { final TableName tableName = TableName.valueOf(TEST_TABLE.getNameAsString() + "." + name.getMethodName()); Table table = util.createTable(tableName, new byte[][] { A, B, C }); try { verifyMethodResult(SimpleRegionObserver.class, new String[] { "hadPreGet", "hadPostGet", "hadPrePut", "hadPostPut", "hadDeleted" }, tableName, new Boolean[] { false, false, false, false, false }); Put put = new Put(ROW); put.addColumn(A, A, A); put.addColumn(B, B, B); put.addColumn(C, C, C); Delete delete = new Delete(ROW); delete.addColumn(A, A); delete.addColumn(B, B); delete.addColumn(C, C); RowMutations arm = new RowMutations(ROW); arm.add(put); arm.add(delete); table.mutateRow(arm); verifyMethodResult(SimpleRegionObserver.class, new String[] { "hadPreGet", "hadPostGet", "hadPrePut", "hadPostPut", "hadDeleted" }, tableName, new Boolean[] { false, false, true, true, true }); } finally { util.deleteTable(tableName); table.close(); } }
table.increment(increment); table.delete(delete); table.mutateRow(mutations); } catch (IOException ex) {
mutations.add(delete); table.mutateRow(mutations);
Bytes.toBytes("val10")); mutations.add(put); table.mutateRow(mutations); printStatistics(true, true);
@Override public void mutateRow(RowMutations rm) throws IOException { delegate.mutateRow(rm); }
@Override public void mutateRow(RowMutations rm) throws IOException { delegate.mutateRow(rm); }
@Override public void mutateRow(ByteBuffer table, TRowMutations rowMutations) throws TIOError, TException { checkReadOnlyMode(); Table htable = getTable(table); try { htable.mutateRow(rowMutationsFromThrift(rowMutations)); } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }
@Override public void mutateRow(RowMutations rm) throws IOException { if (tx == null) { throw new IOException("Transaction not started"); } RowMutations transactionalMutations = new RowMutations(); for (Mutation mutation : rm.getMutations()) { if (mutation instanceof Put) { transactionalMutations.add(transactionalizeAction((Put) mutation)); } else if (mutation instanceof Delete) { transactionalMutations.add(transactionalizeAction((Delete) mutation)); } } hTable.mutateRow(transactionalMutations); }
@Override public void mutateRow(ByteBuffer table, TRowMutations rowMutations) throws TIOError, TException { checkReadOnlyMode(); Table htable = getTable(table); try { htable.mutateRow(rowMutationsFromThrift(rowMutations)); } catch (IOException e) { throw getTIOError(e); } finally { closeTable(htable); } }
@Test public void testRowMutationsWithPreBatchMutate() throws Exception { final TableName tableName = TableName.valueOf(name.getMethodName()); testPreBatchMutate(tableName, () -> { try { RowMutations rm = new RowMutations(ROW, 1); Table t = TEST_UTIL.getConnection().getTable(tableName); Put put = new Put(ROW); put.addColumn(FAMILY, QUALIFIER, VALUE); rm.add(put); t.mutateRow(rm); } catch (IOException ex) { throw new RuntimeException(ex); } }); }