@Test public void testNoBulkLoadsWithNoWrites() throws Exception { Put p = new Put(Bytes.toBytes("to_reject")); p.addColumn( Bytes.toBytes(SpaceQuotaHelperForTests.F1), Bytes.toBytes("to"), Bytes.toBytes("reject")); TableName tableName = writeUntilViolationAndVerifyViolation(SpaceViolationPolicy.NO_WRITES, p); // The table is now in violation. Try to do a bulk load ClientServiceCallable<Boolean> callable = helper.generateFileToLoad(tableName, 1, 50); RpcRetryingCallerFactory factory = new RpcRetryingCallerFactory(TEST_UTIL.getConfiguration()); RpcRetryingCaller<Boolean> caller = factory.newCaller(); try { caller.callWithRetries(callable, Integer.MAX_VALUE); fail("Expected the bulk load call to fail!"); } catch (SpaceLimitingException e) { // Pass LOG.trace("Caught expected exception", e); } }
@Test public void testBulkLoading() throws Exception { TableName tn = helper.createTableWithRegions(1); // Set a quota QuotaSettings settings = QuotaSettingsFactory.limitTableSpace( tn, SpaceQuotaHelperForTests.ONE_GIGABYTE, SpaceViolationPolicy.NO_INSERTS); admin.setQuota(settings); ClientServiceCallable<Boolean> callable = helper.generateFileToLoad(tn, 3, 550); // Make sure the files are about as long as we expect FileSystem fs = TEST_UTIL.getTestFileSystem(); FileStatus[] files = fs.listStatus( new Path(fs.getHomeDirectory(), testName.getMethodName() + "_files")); long totalSize = 0; for (FileStatus file : files) { assertTrue( "Expected the file, " + file.getPath() + ", length to be larger than 25KB, but was " + file.getLen(), file.getLen() > 25 * SpaceQuotaHelperForTests.ONE_KILOBYTE); totalSize += file.getLen(); } RpcRetryingCallerFactory factory = new RpcRetryingCallerFactory(TEST_UTIL.getConfiguration()); RpcRetryingCaller<Boolean> caller = factory.<Boolean> newCaller(); assertTrue("The bulk load failed", caller.callWithRetries(callable, Integer.MAX_VALUE)); final long finalTotalSize = totalSize; TEST_UTIL.waitFor(30 * 1000, 500, new SpaceQuotaSnapshotPredicate(conn, tn) { @Override boolean evaluate(SpaceQuotaSnapshot snapshot) throws Exception { return snapshot.getUsage() >= finalTotalSize; } }); }
ClientServiceCallable<Boolean> callable = helper.generateFileToLoad(tn, 2, 525); FileSystem fs = TEST_UTIL.getTestFileSystem(); FileStatus[] files = fs.listStatus(