/** * Test multithreadedTableMappper map/reduce against a multi-region table * @throws IOException * @throws ClassNotFoundException * @throws InterruptedException */ @Test public void testMultithreadedTableMapper() throws IOException, InterruptedException, ClassNotFoundException { runTestOnTable(UTIL.getConnection().getTable(MULTI_REGION_TABLE_NAME)); }
@Test public void testConnectionDefaultUsesCodec() throws Exception { ClusterConnection con = (ClusterConnection) TEST_UTIL.getConnection(); assertTrue(con.hasCellBlockSupport()); }
@Before public void removeAllQuotas() throws Exception { if (helper == null) { helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, new AtomicLong()); } final Connection conn = TEST_UTIL.getConnection(); // Wait for the quota table to be created if (!conn.getAdmin().tableExists(QuotaUtil.QUOTA_TABLE_NAME)) { helper.waitForQuotaTable(conn); } else { // Or, clean up any quotas from previous test runs. helper.removeAllQuotas(conn); assertEquals(0, helper.listNumDefinedQuotas(conn)); } }
public static void verifyRowCount(final HBaseTestingUtility util, final TableName tableName, long expectedRows) throws IOException { Table table = util.getConnection().getTable(tableName); try { assertEquals(expectedRows, util.countRows(table)); } finally { table.close(); } }
private void moveRegion(Table table, int index) throws IOException{ List<Pair<RegionInfo, ServerName>> regions = MetaTableAccessor .getTableRegionsAndLocations(TEST_UTIL.getConnection(), table.getName()); assertEquals(1, regions.size()); RegionInfo regionInfo = regions.get(0).getFirst(); ServerName name = TEST_UTIL.getHBaseCluster().getRegionServer(index).getServerName(); TEST_UTIL.getAdmin().move(regionInfo.getEncodedNameAsBytes(), Bytes.toBytes(name.getServerName())); }
private Table createTable() throws IOException { TableName tableName = TableName.valueOf(name.getMethodName()); HTableDescriptor table = new HTableDescriptor(tableName); HColumnDescriptor fam = new HColumnDescriptor(FAMILY); fam.setNewVersionBehavior(true); fam.setMaxVersions(3); table.addFamily(fam); TEST_UTIL.getHBaseAdmin().createTable(table); return TEST_UTIL.getConnection().getTable(tableName); }
@BeforeClass public static void before() throws Exception { HTU.startMiniCluster(NB_SERVERS); final TableName tableName = TableName.valueOf(TestRegionServerNoMaster.class.getSimpleName()); // Create table then get the single region for our new table. table = HTU.createTable(tableName,HConstants.CATALOG_FAMILY); Put p = new Put(row); p.addColumn(HConstants.CATALOG_FAMILY, row, row); table.put(p); try (RegionLocator locator = HTU.getConnection().getRegionLocator(tableName)) { hri = locator.getRegionLocation(row, false).getRegionInfo(); } regionName = hri.getRegionName(); stopMasterAndAssignMeta(HTU); }
@Override public boolean evaluate() throws Exception { try (Table table = UTIL1.getConnection().getTable(TABLE_NAME)) { return table.exists(new Get(Bytes.toBytes(0))); } }
private void prepareTest(String testId) throws IOException { tableName = TableName.valueOf("test_table_" + testId); HTableDescriptor htd = new HTableDescriptor(tableName); hcd = new HColumnDescriptor(CF); htd.addFamily(hcd); try (Admin admin = TEST_UTIL.getConnection().getAdmin()) { admin.createTable(htd); } numBatchesWritten = 0; }
/** * For HADOOP-2579 * @throws IOException */ @Test (expected=TableNotFoundException.class) public void testTableNotFoundExceptionWithoutAnyTables() throws IOException { TableName tableName = TableName .valueOf("testTableNotFoundExceptionWithoutAnyTables"); Table ht = TEST_UTIL.getConnection().getTable(tableName); ht.get(new Get(Bytes.toBytes("e"))); }
@Test public void testSecurityCapabilities() throws Exception { List<SecurityCapability> capabilities = TEST_UTIL.getConnection().getAdmin() .getSecurityCapabilities(); assertTrue("AUTHORIZATION capability is missing", capabilities.contains(SecurityCapability.AUTHORIZATION)); assertTrue("CELL_AUTHORIZATION capability is missing", capabilities.contains(SecurityCapability.CELL_AUTHORIZATION)); }
@Test public void testCombiner() throws IOException { Configuration conf = new Configuration(UTIL.getConfiguration()); // force use of combiner for testing purposes conf.setInt("mapreduce.map.combine.minspills", 1); runTestOnTable(UTIL.getConnection().getTable(MULTI_REGION_TABLE_NAME)); }
@Before public void removeAllQuotas() throws Exception { final Connection conn = TEST_UTIL.getConnection(); if (helper == null) { helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, COUNTER); } // Wait for the quota table to be created if (!conn.getAdmin().tableExists(QuotaUtil.QUOTA_TABLE_NAME)) { helper.waitForQuotaTable(conn); } else { // Or, clean up any quotas from previous test runs. helper.removeAllQuotas(conn); assertEquals(0, helper.listNumDefinedQuotas(conn)); } }
@Override protected Table createTable(byte[] fam) throws IOException { TableName tableName = TableName.valueOf(testName.getMethodName()); TEST_UTIL.getAdmin().createTable(TableDescriptorBuilder.newBuilder(tableName) .setColumnFamily(ColumnFamilyDescriptorBuilder.of(fam)).build()); return TEST_UTIL.getConnection().getTable(tableName); }
public int testGet(final RegionInfo hri, final int nrows) throws IOException { int nresults = 0; final Table table = UTIL.getConnection().getTable(hri.getTable()); for (int i = 0; i < nrows; ++i) { final byte[] row = Bytes.add(hri.getStartKey(), Bytes.toBytes(i)); final Result result = table.get(new Get(row)); if (result != null && !result.isEmpty() && Bytes.equals(row, result.getValue(FAMILY, null))) { nresults++; } } return nresults; } }
@Test public void testCachingForHTableSinglePut() throws Exception { byte[] row = Bytes.toBytes("htable_single_put"); byte[] value = Bytes.toBytes("value"); Put put = new Put(row); put.addColumn(FAMILY, QUALIFIER, value); try (Table table = TEST_UTIL.getConnection().getTable(TABLE_NAME)) { table.put(put); } checkRegionLocationIsCached(TABLE_NAME, TEST_UTIL.getConnection()); checkExistence(TABLE_NAME, row, FAMILY, QUALIFIER); }
@Test public void testSecurityCapabilities() throws Exception { List<SecurityCapability> capabilities = TEST_UTIL.getConnection().getAdmin() .getSecurityCapabilities(); assertTrue("CELL_VISIBILITY capability is missing", capabilities.contains(SecurityCapability.CELL_VISIBILITY)); }
@Test public void testNullCall() throws Throwable { try (Table table = util.getConnection().getTable(TEST_TABLE); RegionLocator locator = util.getConnection().getRegionLocator(TEST_TABLE)) { Map<byte[],String> results = hello(table, null, ROW_A, ROW_C); verifyRegionResults(locator, results, "Who are you?", ROW_A); verifyRegionResults(locator, results, "Who are you?", ROW_B); verifyRegionResults(locator, results, "Who are you?", ROW_C); } }
@Before public void removeAllQuotas() throws Exception { final Connection conn = TEST_UTIL.getConnection(); if (helper == null) { helper = new SpaceQuotaHelperForTests(TEST_UTIL, testName, COUNTER); } // Wait for the quota table to be created if (!conn.getAdmin().tableExists(QuotaUtil.QUOTA_TABLE_NAME)) { helper.waitForQuotaTable(conn); } else { // Or, clean up any quotas from previous test runs. helper.removeAllQuotas(conn); assertEquals(0, helper.listNumDefinedQuotas(conn)); } }