org.apache.hadoop.hbase.client.Put.addColumn() - java examples

Here are the examples of the java api org.apache.hadoop.hbase.client.Put.addColumn() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

155 Examples 7

17 View Complete Implementation : TestRegionObserverBypass.java
Copyright Apache License 2.0
Author : apache
/**
 * do a single put that is bypreplaceded by a RegionObserver
 * @throws Exception
 */
@Test
public void testSimple() throws Exception {
    Table t = util.getConnection().getTable(tableName);
    Put p = new Put(row1);
    p.addColumn(test, dummy, dummy);
    // before HBASE-4331, this would throw an exception
    t.put(p);
    checkRowAndDelete(t, row1, 0);
    t.close();
}

17 View Complete Implementation : TestClientOperationTimeout.java
Copyright Apache License 2.0
Author : apache
/**
 * Tests that a put on a table throws {@link SocketTimeoutException} when the operation takes
 * longer than 'hbase.client.operation.timeout'.
 */
@Test(expected = RetriesExhaustedException.clreplaced)
public void testPutTimeout() throws Exception {
    DELAY_MUTATE = 600;
    Put put = new Put(ROW);
    put.addColumn(FAMILY, QUALIFIER, VALUE);
    TABLE.put(put);
}

17 View Complete Implementation : QuotaTableUtil.java
Copyright Apache License 2.0
Author : apache
/**
 * Creates a {@link Put} to persist the current size of the {@code snapshot} with respect to
 * the given {@code table}.
 */
static Put createPutForSnapshotSize(TableName tableName, String snapshot, long size) {
    // We just need a pb message with some `long usage`, so we can just reuse the
    // SpaceQuotaSnapshot message instead of creating a new one.
    Put p = new Put(getTableRowKey(tableName));
    p.addColumn(QUOTA_FAMILY_USAGE, getSnapshotSizeQualifier(snapshot), org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuotaSnapshot.newBuilder().setQuotaUsage(size).build().toByteArray());
    return p;
}

17 View Complete Implementation : TimestampTestBase.java
Copyright Apache License 2.0
Author : apache
/*
   * Put values.
   * @param loader
   * @param bytes
   * @param ts
   * @throws IOException
   */
public static void put(final Table loader, final byte[] bytes, final long ts) throws IOException {
    Put put = new Put(ROW, ts);
    put.setDurability(Durability.SKIP_WAL);
    put.addColumn(FAMILY_NAME, QUALIFIER_NAME, bytes);
    loader.put(put);
}

16 View Complete Implementation : TestScannerRetriableFailure.java
Copyright Apache License 2.0
Author : apache
public void loadTable(final Table table, int numRows) throws IOException {
    List<Put> puts = new ArrayList<>(numRows);
    for (int i = 0; i < numRows; ++i) {
        byte[] row = Bytes.toBytes(String.format("%09d", i));
        Put put = new Put(row);
        put.setDurability(Durability.SKIP_WAL);
        put.addColumn(FAMILY_NAME, null, row);
        table.put(put);
    }
}

16 View Complete Implementation : TestWarmupRegion.java
Copyright Apache License 2.0
Author : apache
/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    table = TEST_UTIL.createTable(TABLENAME, FAMILY);
    // future timestamp
    for (int i = 0; i < numRows; i++) {
        long ts = System.currentTimeMillis() * 2;
        Put put = new Put(ROW, ts);
        put.addColumn(FAMILY, COLUMN, VALUE);
        table.put(put);
    }
    // major compaction, purged future deletes
    TEST_UTIL.getAdmin().flush(TABLENAME);
    TEST_UTIL.getAdmin().majorCompact(TABLENAME);
    // waiting for the major compaction to complete
    TEST_UTIL.waitFor(6000, new Waiter.Predicate<IOException>() {

        @Override
        public boolean evaluate() throws IOException {
            return TEST_UTIL.getAdmin().getCompactionState(TABLENAME) == CompactionState.NONE;
        }
    });
    table.close();
}

16 View Complete Implementation : TestScanModifyingObserver.java
Copyright Apache License 2.0
Author : apache
private void writeData(Table t) throws IOException {
    List<Put> puts = new ArrayList<>(NUM_ROWS);
    for (int i = 0; i < NUM_ROWS; i++) {
        Put p = new Put(Bytes.toBytes(i + 1));
        p.addColumn(FAMILY, EXPLICIT_QUAL, EXPLICIT_VAL);
        p.addColumn(FAMILY, IMPLICIT_QUAL, IMPLICIT_VAL);
        puts.add(p);
    }
    t.put(puts);
}

16 View Complete Implementation : TestNegativeMemStoreSizeWithSlowCoprocessor.java
Copyright Apache License 2.0
Author : apache
@Test
public void testNegativeMemstoreSize() throws IOException, InterruptedException {
    boolean IOEthrown = false;
    Table table = null;
    try {
        table = TEST_UTIL.getConnection().getTable(TableName.valueOf(tableName));
        // Adding data
        Put put1 = new Put(Bytes.toBytes("row1"));
        put1.addColumn(family, qualifier, Bytes.toBytes("Value1"));
        table.put(put1);
        Put put2 = new Put(Bytes.toBytes("row2"));
        put2.addColumn(family, qualifier, Bytes.toBytes("Value2"));
        table.put(put2);
        table.put(put2);
    } catch (IOException e) {
        IOEthrown = true;
    } finally {
        replacedert.replacedertFalse("Shouldn't have thrown an exception", IOEthrown);
        if (table != null) {
            table.close();
        }
    }
}

16 View Complete Implementation : TestRowProcessorEndpoint.java
Copyright Apache License 2.0
Author : apache
public void prepareTestData() throws Exception {
    try {
        util.getAdmin().disableTable(TABLE);
        util.getAdmin().deleteTable(TABLE);
    } catch (Exception e) {
    // ignore table not found
    }
    table = util.createTable(TABLE, FAM);
    {
        Put put = new Put(ROW);
        // B, C are friends of A
        put.addColumn(FAM, A, Bytes.add(B, C));
        // D, E, F are friends of B
        put.addColumn(FAM, B, Bytes.add(D, E, F));
        // G is a friend of C
        put.addColumn(FAM, C, G);
        table.put(put);
        rowSize = put.size();
    }
    Put put = new Put(ROW2);
    put.addColumn(FAM, D, E);
    put.addColumn(FAM, F, G);
    table.put(put);
    row2Size = put.size();
}

15 View Complete Implementation : TestRegionServerMetrics.java
Copyright Apache License 2.0
Author : apache
@Test
public void testCheckAndPutCount() throws Exception {
    byte[] valOne = Bytes.toBytes("Value");
    byte[] valTwo = Bytes.toBytes("ValueTwo");
    byte[] valThree = Bytes.toBytes("ValueThree");
    Put p = new Put(row);
    p.addColumn(cf, qualifier, valOne);
    table.put(p);
    Put pTwo = new Put(row);
    pTwo.addColumn(cf, qualifier, valTwo);
    table.checkAndMutate(row, cf).qualifier(qualifier).ifEquals(valOne).thenPut(pTwo);
    Put pThree = new Put(row);
    pThree.addColumn(cf, qualifier, valThree);
    table.checkAndMutate(row, cf).qualifier(qualifier).ifEquals(valOne).thenPut(pThree);
    metricsRegionServer.getRegionServerWrapper().forceRecompute();
    replacedertCounter("checkMutateFailedCount", 1);
    replacedertCounter("checkMutatePreplacededCount", 1);
}

15 View Complete Implementation : TestTableMapReduceUtil.java
Copyright Apache License 2.0
Author : apache
private static void createPutCommand(Table table) throws IOException {
    for (String president : presidentsRowKeys) {
        if (presidentNames.hasNext()) {
            Put p = new Put(Bytes.toBytes(president));
            p.addColumn(COLUMN_FAMILY, COLUMN_QUALIFIER, Bytes.toBytes(presidentNames.next()));
            table.put(p);
        }
    }
    for (String actor : actorsRowKeys) {
        if (actorNames.hasNext()) {
            Put p = new Put(Bytes.toBytes(actor));
            p.addColumn(COLUMN_FAMILY, COLUMN_QUALIFIER, Bytes.toBytes(actorNames.next()));
            table.put(p);
        }
    }
}

15 View Complete Implementation : TestCompactionState.java
Copyright Apache License 2.0
Author : apache
private static void loadData(final Table ht, final byte[][] families, final int rows, final int flushes) throws IOException {
    List<Put> puts = new ArrayList<>(rows);
    byte[] qualifier = Bytes.toBytes("val");
    for (int i = 0; i < flushes; i++) {
        for (int k = 0; k < rows; k++) {
            byte[] row = Bytes.toBytes(random.nextLong());
            Put p = new Put(row);
            for (int j = 0; j < families.length; ++j) {
                p.addColumn(families[j], qualifier, row);
            }
            puts.add(p);
        }
        ht.put(puts);
        TEST_UTIL.flush();
        puts.clear();
    }
}

15 View Complete Implementation : WALPerformanceEvaluation.java
Copyright Apache License 2.0
Author : apache
private Put setupPut(Random rand, byte[] key, byte[] value, final int numFamilies) {
    rand.nextBytes(key);
    Put put = new Put(key);
    for (int cf = 0; cf < numFamilies; ++cf) {
        for (int q = 0; q < numQualifiers; ++q) {
            rand.nextBytes(value);
            put.addColumn(Bytes.toBytes(FAMILY_PREFIX + cf), Bytes.toBytes(QUALIFIER_PREFIX + q), value);
        }
    }
    return put;
}

15 View Complete Implementation : TestForceCacheImportantBlocks.java
Copyright Apache License 2.0
Author : apache
private void writeTestData(HRegion region) throws IOException {
    for (int i = 0; i < NUM_ROWS; ++i) {
        Put put = new Put(Bytes.toBytes("row" + i));
        for (int j = 0; j < NUM_COLS_PER_ROW; ++j) {
            for (long ts = 1; ts < NUM_TIMESTAMPS_PER_COL; ++ts) {
                put.addColumn(CF_BYTES, Bytes.toBytes("col" + j), ts, Bytes.toBytes("value" + i + "_" + j + "_" + ts));
            }
        }
        region.put(put);
        if ((i + 1) % ROWS_PER_HFILE == 0) {
            region.flush(true);
        }
    }
}

15 View Complete Implementation : TestSpaceQuotaRemoval.java
Copyright Apache License 2.0
Author : apache
private void setQuotaAndThenRemoveInOneAmongTwoTables(SpaceViolationPolicy policy) throws Exception {
    Put put = new Put(Bytes.toBytes("to_reject"));
    put.addColumn(Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"), Bytes.toBytes("reject"));
    // Do puts until we violate space policy on table tn1
    final TableName tn1 = helper.writeUntilViolationAndVerifyViolation(policy, put);
    // Do puts until we violate space policy on table tn2
    final TableName tn2 = helper.writeUntilViolationAndVerifyViolation(policy, put);
    // Now, remove the quota from table tn1
    helper.removeQuotaFromtable(tn1);
    // Put a new row now on tn1: should not violate as quota settings removed
    helper.verifyNoViolation(tn1, put);
    // Put a new row now on tn2: should violate as quota settings exists
    helper.verifyViolation(policy, tn2, put);
}

15 View Complete Implementation : TestSpaceQuotaIncrease.java
Copyright Apache License 2.0
Author : apache
private void setQuotaAndThenIncreaseQuota(SpaceViolationPolicy policy) throws Exception {
    Put put = new Put(Bytes.toBytes("to_reject"));
    put.addColumn(Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"), Bytes.toBytes("reject"));
    // Do puts until we violate space policy
    final TableName tn = helper.writeUntilViolationAndVerifyViolation(policy, put);
    // Now, increase limit and perform put
    helper.setQuotaLimit(tn, policy, 4L);
    // Put some row now: should not violate as quota limit increased
    helper.verifyNoViolation(tn, put);
}

15 View Complete Implementation : TestTableInputFormat.java
Copyright Apache License 2.0
Author : apache
/**
 * Setup a table with two rows and values per column family.
 *
 * @param tableName
 * @return A Table instance for the created table.
 * @throws IOException
 */
public static Table createTable(byte[] tableName, byte[][] families) throws IOException {
    Table table = UTIL.createTable(TableName.valueOf(tableName), families);
    Put p = new Put(Bytes.toBytes("aaa"));
    for (byte[] family : families) {
        p.addColumn(family, null, Bytes.toBytes("value aaa"));
    }
    table.put(p);
    p = new Put(Bytes.toBytes("bbb"));
    for (byte[] family : families) {
        p.addColumn(family, null, Bytes.toBytes("value bbb"));
    }
    table.put(p);
    return table;
}

15 View Complete Implementation : TestTableInputFormat.java
Copyright Apache License 2.0
Author : apache
/**
 * Setup a table with two rows and values per column family.
 *
 * @param tableName
 * @return A Table instance for the created table.
 * @throws IOException
 */
public static Table createTable(byte[] tableName, byte[][] families) throws IOException {
    Table table = UTIL.createTable(TableName.valueOf(tableName), families);
    Put p = new Put(Bytes.toBytes("aaa"));
    for (byte[] family : families) {
        p.addColumn(family, null, Bytes.toBytes("value aaa"));
    }
    table.put(p);
    p = new Put(Bytes.toBytes("bbb"));
    for (byte[] family : families) {
        p.addColumn(family, null, Bytes.toBytes("value bbb"));
    }
    table.put(p);
    return table;
}

15 View Complete Implementation : TestRegionSplit.java
Copyright Apache License 2.0
Author : apache
private void insertData(final TableName tableName) throws IOException {
    Table t = UTIL.getConnection().getTable(tableName);
    Put p;
    for (int i = 0; i < rowCount / 2; i++) {
        p = new Put(Bytes.toBytes("" + (startRowNum + i)));
        p.addColumn(Bytes.toBytes(ColumnFamilyName), Bytes.toBytes("q1"), Bytes.toBytes(i));
        t.put(p);
        p = new Put(Bytes.toBytes("" + (startRowNum + rowCount - i - 1)));
        p.addColumn(Bytes.toBytes(ColumnFamilyName), Bytes.toBytes("q1"), Bytes.toBytes(i));
        t.put(p);
    }
    UTIL.getAdmin().flush(tableName);
}

15 View Complete Implementation : TestSpaceQuotaRemoval.java
Copyright Apache License 2.0
Author : apache
private void setQuotaAndThenRemove(SpaceViolationPolicy policy) throws Exception {
    Put put = new Put(Bytes.toBytes("to_reject"));
    put.addColumn(Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"), Bytes.toBytes("reject"));
    // Do puts until we violate space policy
    final TableName tn = helper.writeUntilViolationAndVerifyViolation(policy, put);
    // Now, remove the quota
    helper.removeQuotaFromtable(tn);
    // Put some rows now: should not violate as quota settings removed
    helper.verifyNoViolation(tn, put);
}

15 View Complete Implementation : TestBackupBase.java
Copyright Apache License 2.0
Author : apache
protected static void loadTable(Table table) throws Exception {
    // 100 + 1 row to t1_syncup
    Put p;
    for (int i = 0; i < NB_ROWS_IN_BATCH; i++) {
        p = new Put(Bytes.toBytes("row" + i));
        p.setDurability(Durability.SKIP_WAL);
        p.addColumn(famName, qualName, Bytes.toBytes("val" + i));
        table.put(p);
    }
}

15 View Complete Implementation : TestServerCustomProtocol.java
Copyright Apache License 2.0
Author : apache
@Before
public void before() throws Exception {
    final byte[][] SPLIT_KEYS = new byte[][] { ROW_B, ROW_C };
    Table table = util.createTable(TEST_TABLE, TEST_FAMILY, SPLIT_KEYS);
    Put puta = new Put(ROW_A);
    puta.addColumn(TEST_FAMILY, Bytes.toBytes("col1"), Bytes.toBytes(1));
    table.put(puta);
    Put putb = new Put(ROW_B);
    putb.addColumn(TEST_FAMILY, Bytes.toBytes("col1"), Bytes.toBytes(1));
    table.put(putb);
    Put putc = new Put(ROW_C);
    putc.addColumn(TEST_FAMILY, Bytes.toBytes("col1"), Bytes.toBytes(1));
    table.put(putc);
}

15 View Complete Implementation : TestParallelPut.java
Copyright Apache License 2.0
Author : apache
// ////////////////////////////////////////////////////////////////////////////
// New tests that don't spin up a mini cluster but rather just test the
// individual code pieces in the HRegion.
// ////////////////////////////////////////////////////////////////////////////
/**
 * Test one put command.
 */
@Test
public void testPut() throws IOException {
    LOG.info("Starting testPut");
    this.region = initHRegion(tableName, getName(), fam1);
    long value = 1L;
    Put put = new Put(row);
    put.addColumn(fam1, qual1, Bytes.toBytes(value));
    region.put(put);
    replacedertGet(this.region, row, fam1, qual1, Bytes.toBytes(value));
}

15 View Complete Implementation : TestSimpleRegionNormalizerOnCluster.java
Copyright Apache License 2.0
Author : apache
private void generateTestData(Region region, int numRows) throws IOException {
    // generating 1Mb values
    LoadTestKVGenerator dataGenerator = new LoadTestKVGenerator(1024 * 1024, 1024 * 1024);
    for (int i = 0; i < numRows; ++i) {
        byte[] key = Bytes.add(region.getRegionInfo().getStartKey(), Bytes.toBytes(i));
        for (int j = 0; j < 1; ++j) {
            Put put = new Put(key);
            byte[] col = Bytes.toBytes(String.valueOf(j));
            byte[] value = dataGenerator.generateRandomSizeValue(key, col);
            put.addColumn(FAMILYNAME, col, value);
            region.put(put);
        }
    }
}

15 View Complete Implementation : TestFilterWithScanLimits.java
Copyright Apache License 2.0
Author : apache
@BeforeClreplaced
public static void prepareData() {
    try {
        createTable(tableName, columnFamily);
        Table table = openTable(tableName);
        List<Put> puts = new ArrayList<>();
        // row1 => <f1:c1, 1_c1>, <f1:c2, 1_c2>, <f1:c3, 1_c3>, <f1:c4,1_c4>,
        // <f1:c5, 1_c5>
        // row2 => <f1:c1, 2_c1>, <f1:c2, 2_c2>, <f1:c3, 2_c3>, <f1:c4,2_c4>,
        // <f1:c5, 2_c5>
        for (int i = 1; i < 4; i++) {
            Put put = new Put(Bytes.toBytes("row" + i));
            for (int j = 1; j < 6; j++) {
                put.addColumn(Bytes.toBytes("f1"), Bytes.toBytes("c" + j), Bytes.toBytes(i + "_c" + j));
            }
            puts.add(put);
        }
        table.put(puts);
        table.close();
    } catch (IOException e) {
        replacedertNull("Exception found while putting data into table", e);
    }
}

14 View Complete Implementation : TestSpaceQuotaSwitchPolicies.java
Copyright Apache License 2.0
Author : apache
private void setQuotaAndViolateNextSwitchPoliciesAndValidate(SpaceViolationPolicy policy1, SpaceViolationPolicy policy2) throws Exception {
    Put put = new Put(Bytes.toBytes("to_reject"));
    put.addColumn(Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"), Bytes.toBytes("reject"));
    // Do puts until we violate space violation policy1
    final TableName tn = helper.writeUntilViolationAndVerifyViolation(policy1, put);
    // Now, change violation policy to policy2
    helper.setQuotaLimit(tn, policy2, 2L);
    // The table should be in enabled state on changing violation policy
    if (policy1.equals(SpaceViolationPolicy.DISABLE) && !policy1.equals(policy2)) {
        TEST_UTIL.waitTableEnabled(tn, 20000);
    }
    // Put some row now: should still violate as quota limit still violated
    helper.verifyViolation(policy2, tn, put);
}

14 View Complete Implementation : TestRowCounter.java
Copyright Apache License 2.0
Author : apache
/**
 * Test a case when the timerange is specified with --starttime and --endtime options
 *
 * @throws Exception
 */
@Test
public void testRowCounterTimeRange() throws Exception {
    final byte[] family = Bytes.toBytes(COL_FAM);
    final byte[] col1 = Bytes.toBytes(COL1);
    Put put1 = new Put(Bytes.toBytes("row_timerange_" + 1));
    Put put2 = new Put(Bytes.toBytes("row_timerange_" + 2));
    Put put3 = new Put(Bytes.toBytes("row_timerange_" + 3));
    long ts;
    // clean up content of TABLE_NAME
    Table table = TEST_UTIL.createTable(TableName.valueOf(TABLE_NAME_TS_RANGE), Bytes.toBytes(COL_FAM));
    ts = System.currentTimeMillis();
    put1.addColumn(family, col1, ts, Bytes.toBytes("val1"));
    table.put(put1);
    Thread.sleep(100);
    ts = System.currentTimeMillis();
    put2.addColumn(family, col1, ts, Bytes.toBytes("val2"));
    put3.addColumn(family, col1, ts, Bytes.toBytes("val3"));
    table.put(put2);
    table.put(put3);
    table.close();
    String[] args = new String[] { TABLE_NAME_TS_RANGE, COL_FAM + ":" + COL1, "--starttime=" + 0, "--endtime=" + ts };
    runRowCount(args, 1);
    args = new String[] { TABLE_NAME_TS_RANGE, COL_FAM + ":" + COL1, "--starttime=" + 0, "--endtime=" + (ts - 10) };
    runRowCount(args, 1);
    args = new String[] { TABLE_NAME_TS_RANGE, COL_FAM + ":" + COL1, "--starttime=" + ts, "--endtime=" + (ts + 1000) };
    runRowCount(args, 2);
    args = new String[] { TABLE_NAME_TS_RANGE, COL_FAM + ":" + COL1, "--starttime=" + (ts - 30 * 1000), "--endtime=" + (ts + 30 * 1000) };
    runRowCount(args, 3);
}

14 View Complete Implementation : VisibilityLabelsWithDeletesTestBase.java
Copyright Apache License 2.0
Author : apache
private Table createTableAndWriteDataWithLabels(String... labelExps) throws Exception {
    Table table = createTable(fam);
    int i = 1;
    List<Put> puts = new ArrayList<>(labelExps.length);
    for (String labelExp : labelExps) {
        Put put = new Put(Bytes.toBytes("row" + i));
        put.addColumn(fam, qual, HConstants.LATEST_TIMESTAMP, value);
        put.setCellVisibility(new CellVisibility(labelExp));
        puts.add(put);
        table.put(put);
        i++;
    }
    // table.put(puts);
    return table;
}

14 View Complete Implementation : TestHBaseFsckCleanReplicationBarriers.java
Copyright Apache License 2.0
Author : apache
private void addStateAndBarrier(RegionInfo region, RegionState.State state, long... barriers) throws IOException {
    Put put = new Put(region.getRegionName(), EnvironmentEdgeManager.currentTime());
    if (state != null) {
        put.addColumn(HConstants.CATALOG_FAMILY, HConstants.STATE_QUALIFIER, Bytes.toBytes(state.name()));
    }
    for (int i = 0; i < barriers.length; i++) {
        put.addColumn(HConstants.REPLICATION_BARRIER_FAMILY, HConstants.SEQNUM_QUALIFIER, put.getTimestamp() - barriers.length + i, Bytes.toBytes(barriers[i]));
    }
    try (Table table = UTIL.getConnection().getTable(TableName.META_TABLE_NAME)) {
        table.put(put);
    }
}

14 View Complete Implementation : TestZooKeeperTableArchiveClient.java
Copyright Apache License 2.0
Author : apache
/**
 * Create a new hfile in the preplaceded region
 * @param region region to operate on
 * @param columnFamily family for which to add data
 * @throws IOException if doing the put or flush fails
 */
private void createHFileInRegion(HRegion region, byte[] columnFamily) throws IOException {
    // put one row in the region
    Put p = new Put(Bytes.toBytes("row"));
    p.addColumn(columnFamily, Bytes.toBytes("Qual"), Bytes.toBytes("v1"));
    region.put(p);
    // flush the region to make a store file
    region.flush(true);
}

14 View Complete Implementation : TestSpaceQuotaBasicFunctioning.java
Copyright Apache License 2.0
Author : apache
@Test
public void testNoWritesWithPut() throws Exception {
    Put p = new Put(Bytes.toBytes("to_reject"));
    p.addColumn(Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"), Bytes.toBytes("reject"));
    helper.writeUntilViolationAndVerifyViolation(SpaceViolationPolicy.NO_WRITES, p);
}

14 View Complete Implementation : TestSpaceQuotasWithRegionReplicas.java
Copyright Apache License 2.0
Author : apache
private void setQuotaAndVerifyForRegionReplication(int region, int replicatedRegion, SpaceViolationPolicy policy) throws Exception {
    TableName tn = helper.createTableWithRegions(TEST_UTIL.getAdmin(), NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR, region, replicatedRegion);
    helper.setQuotaLimit(tn, policy, 5L);
    helper.writeData(tn, 5L * SpaceQuotaHelperForTests.ONE_MEGABYTE);
    Put p = new Put(Bytes.toBytes("to_reject"));
    p.addColumn(Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"), Bytes.toBytes("reject"));
    helper.verifyViolation(policy, tn, p);
}

14 View Complete Implementation : TestMergeTableRegionsProcedure.java
Copyright Apache License 2.0
Author : apache
private int loadARowPerRegion(final Table t, List<RegionInfo> ris) throws IOException {
    List<Put> puts = new ArrayList<>();
    for (RegionInfo ri : ris) {
        Put put = new Put(ri.getStartKey() == null || ri.getStartKey().length == 0 ? new byte[] { 'a' } : ri.getStartKey());
        put.addColumn(HConstants.CATALOG_FAMILY, HConstants.CATALOG_FAMILY, HConstants.CATALOG_FAMILY);
        puts.add(put);
    }
    t.put(puts);
    return puts.size();
}

14 View Complete Implementation : TestSpaceQuotaBasicFunctioning.java
Copyright Apache License 2.0
Author : apache
@Test
public void testNoInsertsWithPut() throws Exception {
    Put p = new Put(Bytes.toBytes("to_reject"));
    p.addColumn(Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"), Bytes.toBytes("reject"));
    helper.writeUntilViolationAndVerifyViolation(SpaceViolationPolicy.NO_INSERTS, p);
}

14 View Complete Implementation : OfflineMetaRebuildTestCore.java
Copyright Apache License 2.0
Author : apache
private void populateTable(Table tbl) throws IOException {
    byte[] values = { 'A', 'B', 'C', 'D' };
    List<Put> puts = new ArrayList<>();
    for (int i = 0; i < values.length; i++) {
        for (int j = 0; j < values.length; j++) {
            Put put = new Put(new byte[] { values[i], values[j] });
            put.addColumn(Bytes.toBytes("fam"), new byte[] {}, new byte[] { values[i], values[j] });
            puts.add(put);
        }
    }
    tbl.put(puts);
}

14 View Complete Implementation : TestReplicationChangingPeerRegionservers.java
Copyright Apache License 2.0
Author : apache
private void doPutTest(byte[] row) throws IOException, InterruptedException {
    Put put = new Put(row);
    put.addColumn(famName, row, row);
    if (htable1 == null) {
        htable1 = UTIL1.getConnection().getTable(tableName);
    }
    htable1.put(put);
    Get get = new Get(row);
    for (int i = 0; i < NB_RETRIES; i++) {
        if (i == NB_RETRIES - 1) {
            fail("Waited too much time for put replication");
        }
        Result res = htable2.get(get);
        if (res.isEmpty()) {
            LOG.info("Row not available");
            Thread.sleep(SLEEP_TIME);
        } else {
            replacedertArrayEquals(res.value(), row);
            break;
        }
    }
}

13 View Complete Implementation : TestMobDataBlockEncoding.java
Copyright Apache License 2.0
Author : apache
public void testDataBlockEncoding(DataBlockEncoding encoding) throws Exception {
    String TN = "testDataBlockEncoding" + encoding;
    setUp(defaultThreshold, TN, encoding);
    long ts1 = System.currentTimeMillis();
    long ts2 = ts1 + 1;
    long ts3 = ts1 + 2;
    byte[] value = generateMobValue((int) defaultThreshold + 1);
    Put put1 = new Put(row1);
    put1.addColumn(family, qf1, ts3, value);
    put1.addColumn(family, qf2, ts2, value);
    put1.addColumn(family, qf3, ts1, value);
    table.put(put1);
    admin.flush(TableName.valueOf(TN));
    Scan scan = new Scan();
    scan.setMaxVersions(4);
    MobTestUtil.replacedertCellsValue(table, scan, value, 3);
}

13 View Complete Implementation : TestHBaseOnOtherDfsCluster.java
Copyright Apache License 2.0
Author : apache
@Test
public void testOveralyOnOtherCluster() throws Exception {
    // just run HDFS
    HBaseTestingUtility util1 = new HBaseTestingUtility();
    MiniDFSCluster dfs = util1.startMiniDFSCluster(1);
    // run HBase on that HDFS
    HBaseTestingUtility util2 = new HBaseTestingUtility();
    // set the dfs
    util2.setDFSCluster(dfs, false);
    util2.startMiniCluster();
    // ensure that they are pointed at the same place
    FileSystem fs = dfs.getFileSystem();
    FileSystem targetFs = util2.getDFSCluster().getFileSystem();
    replacedertFsSameUri(fs, targetFs);
    fs = FileSystem.get(util1.getConfiguration());
    targetFs = FileSystem.get(util2.getConfiguration());
    replacedertFsSameUri(fs, targetFs);
    Path randomFile = new Path("/" + util1.getRandomUUID());
    replacedertTrue(targetFs.createNewFile(randomFile));
    replacedertTrue(fs.exists(randomFile));
    // do a simple create/write to ensure the cluster works as expected
    byte[] family = Bytes.toBytes("testfamily");
    final TableName tablename = TableName.valueOf(name.getMethodName());
    Table table = util2.createTable(tablename, family);
    Put p = new Put(new byte[] { 1, 2, 3 });
    p.addColumn(family, null, new byte[] { 1 });
    table.put(p);
    // shutdown and make sure cleanly shutting down
    util2.shutdownMiniCluster();
    util1.shutdownMiniDFSCluster();
}

13 View Complete Implementation : TestConstraint.java
Copyright Apache License 2.0
Author : apache
/**
 * Test that we run a preplaceding constraint
 * @throws Exception
 */
@SuppressWarnings("unchecked")
@Test
public void testConstraintPreplacedes() throws Exception {
    // create the table
    // it would be nice if this was also a method on the util
    HTableDescriptor desc = new HTableDescriptor(tableName);
    for (byte[] family : new byte[][] { dummy, test }) {
        desc.addFamily(new HColumnDescriptor(family));
    }
    // add a constraint
    Constraints.add(desc, CheckWasRunConstraint.clreplaced);
    util.getAdmin().createTable(desc);
    Table table = util.getConnection().getTable(tableName);
    try {
        // test that we don't fail on a valid put
        Put put = new Put(row1);
        byte[] value = Bytes.toBytes(Integer.toString(10));
        byte[] qualifier = new byte[0];
        put.addColumn(dummy, qualifier, value);
        table.put(put);
    } finally {
        table.close();
    }
    replacedertTrue(CheckWasRunConstraint.wasRun);
}

13 View Complete Implementation : TestVisibilityLabelsWithACL.java
Copyright Apache License 2.0
Author : apache
private static Table createTableAndWriteDataWithLabels(TableName tableName, String... labelExps) throws Exception {
    Table table = null;
    try {
        table = TEST_UTIL.createTable(tableName, fam);
        int i = 1;
        List<Put> puts = new ArrayList<>(labelExps.length);
        for (String labelExp : labelExps) {
            Put put = new Put(Bytes.toBytes("row" + i));
            put.addColumn(fam, qual, HConstants.LATEST_TIMESTAMP, value);
            put.setCellVisibility(new CellVisibility(labelExp));
            puts.add(put);
            i++;
        }
        table.put(puts);
    } finally {
        if (table != null) {
            table.close();
        }
    }
    return table;
}

13 View Complete Implementation : TestInvocationRecordFilter.java
Copyright Apache License 2.0
Author : apache
@Before
public void setUp() throws Exception {
    HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(TABLE_NAME_BYTES));
    htd.addFamily(new HColumnDescriptor(FAMILY_NAME_BYTES));
    HRegionInfo info = new HRegionInfo(htd.getTableName(), null, null, false);
    this.region = HBaseTestingUtility.createRegionAndWAL(info, TEST_UTIL.getDataTestDir(), TEST_UTIL.getConfiguration(), htd);
    Put put = new Put(ROW_BYTES);
    for (int i = 0; i < 10; i += 2) {
        // puts 0, 2, 4, 6 and 8
        put.addColumn(FAMILY_NAME_BYTES, Bytes.toBytes(QUALIFIER_PREFIX + i), (long) i, Bytes.toBytes(VALUE_PREFIX + i));
    }
    this.region.put(put);
    this.region.flush(true);
}

13 View Complete Implementation : TestBackupBase.java
Copyright Apache License 2.0
Author : apache
Table insertIntoTable(Connection conn, TableName table, byte[] family, int id, int numRows) throws IOException {
    Table t = conn.getTable(table);
    Put p1;
    for (int i = 0; i < numRows; i++) {
        p1 = new Put(Bytes.toBytes("row-" + table + "-" + id + "-" + i));
        p1.addColumn(family, qualName, Bytes.toBytes("val" + i));
        t.put(p1);
    }
    return t;
}

13 View Complete Implementation : TestFilterWrapper.java
Copyright Apache License 2.0
Author : apache
private static void prepareData() {
    try {
        Table table = connection.getTable(name);
        replacedertTrue("Fail to create the table", admin.tableExists(name));
        List<Put> puts = new ArrayList<>();
        // row1 => <f1:c1, 1_c1, ts=1>, <f1:c2, 1_c2, ts=2>, <f1:c3, 1_c3,ts=3>,
        // <f1:c4,1_c4, ts=4>, <f1:c5, 1_c5, ts=5>
        // row2 => <f1:c1, 2_c1, ts=2>, <f1,c2, 2_c2, ts=2>, <f1:c3, 2_c3,ts=2>,
        // <f1:c4,2_c4, ts=2>, <f1:c5, 2_c5, ts=2>
        // row3 => <f1:c1, 3_c1, ts=3>, <f1:c2, 3_c2, ts=3>, <f1:c3, 3_c3,ts=2>,
        // <f1:c4,3_c4, ts=3>, <f1:c5, 3_c5, ts=3>
        for (int i = 1; i < 4; i++) {
            Put put = new Put(Bytes.toBytes("row" + i));
            for (int j = 1; j < 6; j++) {
                long timestamp = j;
                if (i != 1)
                    timestamp = i;
                put.addColumn(Bytes.toBytes("f1"), Bytes.toBytes("c" + j), timestamp, Bytes.toBytes(i + "_c" + j));
            }
            puts.add(put);
        }
        table.put(puts);
        table.close();
    } catch (IOException e) {
        replacedertNull("Exception found while putting data into table", e);
    }
}

13 View Complete Implementation : TestConstraint.java
Copyright Apache License 2.0
Author : apache
/**
 * Check to make sure a constraint is unloaded when it fails
 * @throws Exception
 */
@Test
public void testIsUnloaded() throws Exception {
    // create the table
    HTableDescriptor desc = new HTableDescriptor(tableName);
    // add a family to the table
    for (byte[] family : new byte[][] { dummy, test }) {
        desc.addFamily(new HColumnDescriptor(family));
    }
    // make sure that constraints are unloaded
    Constraints.add(desc, RuntimeFailConstraint.clreplaced);
    // add a constraint to check to see if is run
    Constraints.add(desc, CheckWasRunConstraint.clreplaced);
    CheckWasRunConstraint.wasRun = false;
    util.getAdmin().createTable(desc);
    Table table = util.getConnection().getTable(tableName);
    // test that we do fail on violation
    Put put = new Put(row1);
    byte[] qualifier = new byte[0];
    put.addColumn(dummy, qualifier, Bytes.toBytes("preplaced"));
    try {
        table.put(put);
        fail("RuntimeFailConstraint wasn't triggered - this put shouldn't work!");
    } catch (Exception e) {
    // NOOP
    }
    // try the put again, this time constraints are not used, so it works
    table.put(put);
    // and we make sure that constraints were not run...
    replacedertFalse(CheckWasRunConstraint.wasRun);
    table.close();
}

13 View Complete Implementation : TestSplitTableRegionProcedure.java
Copyright Apache License 2.0
Author : apache
private void insertData(final TableName tableName) throws IOException, InterruptedException {
    Table t = UTIL.getConnection().getTable(tableName);
    Put p;
    for (int i = 0; i < rowCount / 2; i++) {
        p = new Put(Bytes.toBytes("" + (startRowNum + i)));
        p.addColumn(Bytes.toBytes(ColumnFamilyName1), Bytes.toBytes("q1"), Bytes.toBytes(i));
        p.addColumn(Bytes.toBytes(ColumnFamilyName2), Bytes.toBytes("q2"), Bytes.toBytes(i));
        t.put(p);
        p = new Put(Bytes.toBytes("" + (startRowNum + rowCount - i - 1)));
        p.addColumn(Bytes.toBytes(ColumnFamilyName1), Bytes.toBytes("q1"), Bytes.toBytes(i));
        p.addColumn(Bytes.toBytes(ColumnFamilyName2), Bytes.toBytes("q2"), Bytes.toBytes(i));
        t.put(p);
        if (i % 5 == 0) {
            UTIL.getAdmin().flush(tableName);
        }
    }
}

13 View Complete Implementation : VisibilityLabelsWithDeletesTestBase.java
Copyright Apache License 2.0
Author : apache
private Table createTableAndWriteDataWithLabels(long[] timestamp, String... labelExps) throws Exception {
    Table table = createTable(fam);
    int i = 1;
    List<Put> puts = new ArrayList<>(labelExps.length);
    for (String labelExp : labelExps) {
        Put put = new Put(Bytes.toBytes("row" + i));
        put.addColumn(fam, qual, timestamp[i - 1], value);
        put.setCellVisibility(new CellVisibility(labelExp));
        puts.add(put);
        table.put(put);
        TEST_UTIL.getAdmin().flush(table.getName());
        i++;
    }
    return table;
}

13 View Complete Implementation : TestSplitTransactionOnCluster.java
Copyright Apache License 2.0
Author : apache
private void insertData(final TableName tableName, Admin admin, Table t) throws IOException, InterruptedException {
    Put p = new Put(Bytes.toBytes("row1"));
    p.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("q1"), Bytes.toBytes("1"));
    t.put(p);
    p = new Put(Bytes.toBytes("row2"));
    p.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("q1"), Bytes.toBytes("2"));
    t.put(p);
    p = new Put(Bytes.toBytes("row3"));
    p.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("q1"), Bytes.toBytes("3"));
    t.put(p);
    p = new Put(Bytes.toBytes("row4"));
    p.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("q1"), Bytes.toBytes("4"));
    t.put(p);
    admin.flush(tableName);
}

13 View Complete Implementation : TestRemoteTable.java
Copyright Apache License 2.0
Author : apache
@Test
public void testCheckAndDelete() throws IOException {
    Get get = new Get(ROW_1);
    Result result = remoteTable.get(get);
    byte[] value1 = result.getValue(COLUMN_1, QUALIFIER_1);
    byte[] value2 = result.getValue(COLUMN_2, QUALIFIER_2);
    replacedertNotNull(value1);
    replacedertTrue(Bytes.equals(VALUE_1, value1));
    replacedertNull(value2);
    replacedertTrue(remoteTable.exists(get));
    replacedertEquals(1, remoteTable.exists(Collections.singletonList(get)).length);
    Delete delete = new Delete(ROW_1);
    remoteTable.checkAndMutate(ROW_1, COLUMN_1).qualifier(QUALIFIER_1).ifEquals(VALUE_1).thenDelete(delete);
    replacedertFalse(remoteTable.exists(get));
    Put put = new Put(ROW_1);
    put.addColumn(COLUMN_1, QUALIFIER_1, VALUE_1);
    remoteTable.put(put);
    replacedertTrue(remoteTable.checkAndMutate(ROW_1, COLUMN_1).qualifier(QUALIFIER_1).ifEquals(VALUE_1).thenPut(put));
    replacedertFalse(remoteTable.checkAndMutate(ROW_1, COLUMN_1).qualifier(QUALIFIER_1).ifEquals(VALUE_2).thenPut(put));
}

13 View Complete Implementation : TestMobStoreScanner.java
Copyright Apache License 2.0
Author : apache
private void testGet(TableName tableName, boolean reversed, boolean doFlush) throws Exception {
    setUp(defaultThreshold, tableName);
    long ts1 = System.currentTimeMillis();
    long ts2 = ts1 + 1;
    long ts3 = ts1 + 2;
    byte[] value = generateMobValue((int) defaultThreshold + 1);
    Put put1 = new Put(row1);
    put1.addColumn(family, qf1, ts3, value);
    put1.addColumn(family, qf2, ts2, value);
    put1.addColumn(family, qf3, ts1, value);
    table.put(put1);
    if (doFlush) {
        admin.flush(tableName);
    }
    Scan scan = new Scan();
    setScan(scan, reversed, false);
    MobTestUtil.replacedertCellsValue(table, scan, value, 3);
}

13 View Complete Implementation : TestPerColumnFamilyFlush.java
Copyright Apache License 2.0
Author : apache
private void doPut(Table table, long memstoreFlushSize) throws IOException, InterruptedException {
    Region region = getRegionWithName(table.getName()).getFirst();
    // cf1 4B per row, cf2 40B per row and cf3 400B per row
    byte[] qf = Bytes.toBytes("qf");
    Random rand = new Random();
    byte[] value1 = new byte[100];
    byte[] value2 = new byte[200];
    byte[] value3 = new byte[400];
    for (int i = 0; i < 10000; i++) {
        Put put = new Put(Bytes.toBytes("row-" + i));
        rand.setSeed(i);
        rand.nextBytes(value1);
        rand.nextBytes(value2);
        rand.nextBytes(value3);
        put.addColumn(FAMILY1, qf, value1);
        put.addColumn(FAMILY2, qf, value2);
        put.addColumn(FAMILY3, qf, value3);
        table.put(put);
        // slow down to let regionserver flush region.
        while (region.getMemStoreHeapSize() > memstoreFlushSize) {
            Thread.sleep(100);
        }
    }
}