Skip to content

Commit 5516ed3

Browse files
committed
Merge pull request apache#9 from mapr/mapr-22204
MAPR-22204: Sqoop 1.4.6 failed to import data to HBase 1.1.1
2 parents 7a3bea5 + a7a609b commit 5516ed3

File tree

4 files changed

+53
-2
lines changed

4 files changed

+53
-2
lines changed

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
</if>
202202

203203
<!-- Set dependency versions that are working with all Hadoop versions-->
204-
<property name="hbase95.version" value="0.95.2-hadoop${hbasecompatprofile}-SNAPSHOT" />
204+
<property name="hbase95.version" value="0.95.2-hadoop${hbasecompatprofile}" />
205205

206206
<!-- Load system-wide and project-wide default properties set by
207207
the user, to avoid needing to override with -D. -->

ivy/ivysettings.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ under the License.
4040
<property name="snapshot.apache.org"
4141
value="https://repository.apache.org/content/repositories/snapshots/"
4242
override="false"/>
43+
<property name="release.apache.org"
44+
value="https://repository.apache.org/content/repositories/releases/"
45+
override="false"/>
4346
<property name="staging.cloudera.com"
4447
value="https://repository.cloudera.com/content/repositories/staging/"
4548
override="false"/>
@@ -65,6 +68,8 @@ under the License.
6568
pattern="${maven2.pattern.ext}" m2compatible="true"/>
6669
<ibiblio name="cloudera-releases" root="${releases.cloudera.com}"
6770
pattern="${maven2.pattern.ext}" m2compatible="true"/>
71+
<ibiblio name="apache-release" root="${release.apache.org}"
72+
pattern="${maven2.pattern.ext}" m2compatible="true" />
6873
<ibiblio name="apache-snapshot" root="${snapshot.apache.org}"
6974
m2compatible="true" checkmodified="true" changingPattern=".*SNAPSHOT"/>
7075
<ibiblio name="cloudera-staging" root="${staging.cloudera.com}"
@@ -79,6 +84,7 @@ under the License.
7984
changingPattern=".*SNAPSHOT">
8085
<resolver ref="fs"/>
8186
<resolver ref="mapr-releases"/>
87+
<resolver ref="apache-release"/>
8288
<resolver ref="apache-snapshot"/>
8389
<resolver ref="datanucleus"/>
8490
<resolver ref="cloudera-releases"/>

src/java/org/apache/sqoop/mapreduce/HBaseImportJob.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ protected void jobSetup(Job job) throws IOException, ImportException {
219219
// Create the table.
220220
LOG.info("Creating missing HBase table " + tableName);
221221
tableDesc = new HTableDescriptor(tableName);
222-
tableDesc.addFamily(colDesc);
222+
HTableDescriptorProxy.addFamily(tableDesc, colDesc);
223223
admin.createTable(tableDesc);
224224
} else {
225225
LOG.warn("Could not find HBase table " + tableName);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package org.apache.sqoop.mapreduce;
2+
3+
import java.lang.reflect.Method;
4+
5+
import org.apache.commons.logging.Log;
6+
import org.apache.commons.logging.LogFactory;
7+
import org.apache.hadoop.hbase.HColumnDescriptor;
8+
import org.apache.hadoop.hbase.HTableDescriptor;
9+
10+
public class HTableDescriptorProxy {
11+
12+
private static final Log LOG = LogFactory.getLog(HTableDescriptorProxy.class);
13+
14+
private static boolean addFamily_InitError_ = false;
15+
private static Method addFamily_Method_ = null;
16+
private static RuntimeException addFamily_InitException_ = null;
17+
18+
19+
static {
20+
try {
21+
addFamily_Method_ = HTableDescriptor.class.getMethod("addFamily", HColumnDescriptor.class);
22+
} catch (Exception e) {
23+
addFamily_InitException_ = new RuntimeException("cannot find org.apache.hadoop.hbase.HTableDescriptor.addFamily(HColumnDescriptor) ", e);
24+
addFamily_InitError_ = true;
25+
}
26+
}
27+
28+
public static void addFamily(HTableDescriptor object, HColumnDescriptor param) {
29+
if (addFamily_InitError_) {
30+
throw addFamily_InitException_;
31+
}
32+
33+
try {
34+
if (addFamily_Method_ != null) {
35+
LOG.debug("Call HTableDescriptor::addFamily()");
36+
addFamily_Method_.invoke(object, param);
37+
return;
38+
}
39+
throw new RuntimeException("No HTableDescriptor::addFamily() function found.");
40+
} catch (Exception e) {
41+
throw new RuntimeException(e);
42+
}
43+
}
44+
45+
}

0 commit comments

Comments
 (0)