apurtell commented on code in PR #4592: URL: https://github.com/apache/hbase/pull/4592#discussion_r912267146
########## hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFileBlockUnpack.java: ########## @@ -0,0 +1,169 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.io.hfile; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.util.Random; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FSDataInputStream; +import org.apache.hadoop.fs.FSDataOutputStream; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.hbase.HBaseClassTestRule; +import org.apache.hadoop.hbase.HBaseConfiguration; +import org.apache.hadoop.hbase.HBaseTestingUtil; +import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.fs.HFileSystem; +import org.apache.hadoop.hbase.io.ByteBuffAllocator; +import org.apache.hadoop.hbase.io.FSDataInputStreamWrapper; +import org.apache.hadoop.hbase.io.compress.Compression; +import org.apache.hadoop.hbase.testclassification.IOTests; +import org.apache.hadoop.hbase.testclassification.MediumTests; +import org.apache.hadoop.hbase.util.Bytes; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.TestName; + +@Category({ IOTests.class, MediumTests.class }) +public class TestHFileBlockUnpack { + + @ClassRule + public static final HBaseClassTestRule CLASS_RULE = + HBaseClassTestRule.forClass(TestHFileBlockUnpack.class); + + private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil(); + + // repetition gives us some chance to get a good compression ratio + private static float CHANCE_TO_REPEAT = 0.6f; + + private static final int MIN_ALLOCATION_SIZE = 10 * 1024; + + ByteBuffAllocator allocator; + + @Rule + public TestName name = new TestName(); + private FileSystem fs; + + @Before + public void setUp() throws Exception { + fs = HFileSystem.get(TEST_UTIL.getConfiguration()); + Configuration conf = HBaseConfiguration.create(TEST_UTIL.getConfiguration()); + conf.setInt(ByteBuffAllocator.MIN_ALLOCATE_SIZE_KEY, MIN_ALLOCATION_SIZE); + allocator = ByteBuffAllocator.create(conf, true); + + } + + /** + * If the block on disk size is less than {@link ByteBuffAllocator}'s min allocation size, that + * block will be allocated to heap regardless of desire for off-heap. After de-compressing the + * block, the new size may now exceed the min allocation size. This test ensures that those + * de-compressed blocks, which will be allocated off-heap, are properly marked as + * {@link HFileBlock#isSharedMem()} == true See https://issues.apache.org/jira/browse/HBASE-27170 + */ + @Test Review Comment: Nice test, thank you ########## hbase-common/src/main/java/org/apache/hadoop/hbase/nio/RefCnt.java: ########## @@ -31,7 +34,10 @@ @InterfaceAudience.Private public class RefCnt extends AbstractReferenceCounted { - private Recycler recycler = ByteBuffAllocator.NONE; + private static final ResourceLeakDetector<RefCnt> detector = Review Comment: I suppose it is not worth importing the ResourceLeakDetector code. How likely would netty change it? Pretty unlikely, I'd think. And we already use so many other netty types directly... Just thinking out loud. ########## hbase-common/src/test/java/org/apache/hadoop/hbase/io/TestByteBuffAllocator.java: ########## @@ -21,6 +21,7 @@ import static org.apache.hadoop.hbase.io.ByteBuffAllocator.getHeapAllocationRatio; Review Comment: Would you consider a new unit here that confirms leak detection works, by leaking deliberately? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
