[
https://issues.apache.org/jira/browse/HBASE-7594?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13559147#comment-13559147
]
Andrew Purtell commented on HBASE-7594:
---------------------------------------
The instantiation check flagged TestHFile as doing something bogus. This is
interesting. TestHFile#testComparator creates an anonymous class which does not
have a nullary constructor so cannot be instantiated. See this disassembly with
javap:
{noformat}
Compiled from "TestHFile.java"
class org.apache.hadoop.hbase.io.hfile.TestHFile$2 extends
org.apache.hadoop.hbase.KeyValue$KeyComparator{
final org.apache.hadoop.hbase.io.hfile.TestHFile this$0;
Signature: Lorg/apache/hadoop/hbase/io/hfile/TestHFile;
org.apache.hadoop.hbase.io.hfile.TestHFile$2(org.apache.hadoop.hbase.io.hfile.TestHFile);
Signature: (Lorg/apache/hadoop/hbase/io/hfile/TestHFile;)V
public int compare(byte[], int, int, byte[], int, int);
Signature: ([BII[BII)I
public int compare(byte[], byte[]);
Signature: ([B[B)I
public int compare(java.lang.Object, java.lang.Object);
Signature: (Ljava/lang/Object;Ljava/lang/Object;)I
}
{noformat}
Note the constructor.
This minor change to TestHFile fixes the problem locally:
{noformat}
--- hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFile.java
(revision 1436569)
+++ hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFile.java
(working copy)
@@ -347,21 +347,25 @@
assertTrue(Compression.Algorithm.LZ4.ordinal() == 4);
}
+ // This can't be an anonymous class because the compiler will not generate
+ // a nullary constructor for it.
+ static class CustomKeyComparator extends KeyComparator {
+ @Override
+ public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2,
+ int l2) {
+ return -Bytes.compareTo(b1, s1, l1, b2, s2, l2);
+ }
+ @Override
+ public int compare(byte[] o1, byte[] o2) {
+ return compare(o1, 0, o1.length, o2, 0, o2.length);
+ }
+ }
+
public void testComparator() throws IOException {
if (cacheConf == null) cacheConf = new CacheConfig(conf);
Path mFile = new Path(ROOT_DIR, "meta.tfile");
FSDataOutputStream fout = createFSOutput(mFile);
- KeyComparator comparator = new KeyComparator() {
- @Override
- public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2,
- int l2) {
- return -Bytes.compareTo(b1, s1, l1, b2, s2, l2);
- }
- @Override
- public int compare(byte[] o1, byte[] o2) {
- return compare(o1, 0, o1.length, o2, 0, o2.length);
- }
- };
+ KeyComparator comparator = new CustomKeyComparator();
Writer writer = HFile.getWriterFactory(conf, cacheConf)
.withOutputStream(fout)
.withBlockSize(minBlockSize)
{noformat}
Will update the patch to include this and try again.
> TestLocalHBaseCluster failing on ubuntu2
> ----------------------------------------
>
> Key: HBASE-7594
> URL: https://issues.apache.org/jira/browse/HBASE-7594
> Project: HBase
> Issue Type: Bug
> Components: test
> Affects Versions: 0.96.0
> Reporter: Andrew Purtell
> Assignee: Andrew Purtell
> Attachments: 7594-1.patch
>
>
> {noformat}
> java.io.IOException: java.io.IOException: java.io.IOException:
> java.lang.InstantiationException: org.apache.hadoop.io.RawComparator
> at
> org.apache.hadoop.hbase.regionserver.HRegion.initializeRegionInternals(HRegion.java:612)
> at
> org.apache.hadoop.hbase.regionserver.HRegion.initialize(HRegion.java:533)
> at
> org.apache.hadoop.hbase.regionserver.HRegion.openHRegion(HRegion.java:4092)
> at
> org.apache.hadoop.hbase.regionserver.HRegion.openHRegion(HRegion.java:4042)
> at
> org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler.openRegion(OpenRegionHandler.java:427)
> at
> org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler.process(OpenRegionHandler.java:130)
> at
> org.apache.hadoop.hbase.executor.EventHandler.run(EventHandler.java:202)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
> at java.lang.Thread.run(Thread.java:662)
> Caused by: java.io.IOException: java.io.IOException:
> java.lang.InstantiationException: org.apache.hadoop.io.RawComparator
> at
> org.apache.hadoop.hbase.regionserver.HStore.loadStoreFiles(HStore.java:450)
> at org.apache.hadoop.hbase.regionserver.HStore.<init>(HStore.java:215)
> at
> org.apache.hadoop.hbase.regionserver.HRegion.instantiateHStore(HRegion.java:3060)
> at org.apache.hadoop.hbase.regionserver.HRegion$1.call(HRegion.java:585)
> at org.apache.hadoop.hbase.regionserver.HRegion$1.call(HRegion.java:583)
> at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
> at java.util.concurrent.FutureTask.run(FutureTask.java:138)
> at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
> at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
> at java.util.concurrent.FutureTask.run(FutureTask.java:138)
> ... 3 more
> Caused by: java.io.IOException: java.lang.InstantiationException:
> org.apache.hadoop.io.RawComparator
> at
> org.apache.hadoop.hbase.io.hfile.FixedFileTrailer.createComparator(FixedFileTrailer.java:607)
> at
> org.apache.hadoop.hbase.io.hfile.FixedFileTrailer.createComparator(FixedFileTrailer.java:615)
> at
> org.apache.hadoop.hbase.io.hfile.HFileReaderV2.<init>(HFileReaderV2.java:115)
> at
> org.apache.hadoop.hbase.io.hfile.HFile.pickReaderVersion(HFile.java:564)
> at
> org.apache.hadoop.hbase.io.hfile.HFile.createReaderWithEncoding(HFile.java:599)
> at
> org.apache.hadoop.hbase.regionserver.StoreFile$Reader.<init>(StoreFile.java:1294)
> at
> org.apache.hadoop.hbase.regionserver.StoreFile.open(StoreFile.java:525)
> at
> org.apache.hadoop.hbase.regionserver.StoreFile.createReader(StoreFile.java:628)
> at org.apache.hadoop.hbase.regionserver.HStore$1.call(HStore.java:426)
> at org.apache.hadoop.hbase.regionserver.HStore$1.call(HStore.java:422)
> ... 8 more
> Caused by: java.lang.InstantiationException:
> org.apache.hadoop.io.RawComparator
> at java.lang.Class.newInstance0(Class.java:340)
> at java.lang.Class.newInstance(Class.java:308)
> at
> org.apache.hadoop.hbase.io.hfile.FixedFileTrailer.createComparator(FixedFileTrailer.java:605)
> ... 17 more
> {noformat}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira