mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
增加adapter assembly打包
This commit is contained in:
@@ -10,6 +10,7 @@ import javax.sql.DataSource;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||
import org.apache.hadoop.hbase.TableName;
|
||||
import org.apache.hadoop.hbase.client.*;
|
||||
import org.apache.hadoop.hbase.client.Result;
|
||||
import org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter;
|
||||
@@ -41,7 +42,6 @@ public class HbaseAdapter implements OuterAdapter {
|
||||
private Connection conn;
|
||||
private HbaseSyncService hbaseSyncService;
|
||||
private HbaseTemplate hbaseTemplate;
|
||||
private Configuration hbaseConfig;
|
||||
|
||||
@Override
|
||||
public void init(OuterAdapterConfig configuration) {
|
||||
@@ -62,7 +62,7 @@ public class HbaseAdapter implements OuterAdapter {
|
||||
|
||||
Map<String, String> propertites = configuration.getProperties();
|
||||
|
||||
hbaseConfig = HBaseConfiguration.create();
|
||||
Configuration hbaseConfig = HBaseConfiguration.create();
|
||||
propertites.forEach(hbaseConfig::set);
|
||||
conn = ConnectionFactory.createConnection(hbaseConfig);
|
||||
hbaseTemplate = new HbaseTemplate(conn);
|
||||
@@ -103,7 +103,7 @@ public class HbaseAdapter implements OuterAdapter {
|
||||
String hbaseTable = config.getHbaseOrm().getHbaseTable();
|
||||
long rowCount = 0L;
|
||||
try {
|
||||
HTable table = new HTable(hbaseConfig, hbaseTable);
|
||||
HTable table = (HTable) conn.getTable(TableName.valueOf(hbaseTable));
|
||||
Scan scan = new Scan();
|
||||
scan.setFilter(new FirstKeyOnlyFilter());
|
||||
ResultScanner resultScanner = table.getScanner(scan);
|
||||
|
||||
@@ -92,6 +92,7 @@ public class TypeUtil {
|
||||
return b;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T toObject(byte[] bytes, Class<T> clazz) {
|
||||
if (bytes == null) {
|
||||
return null;
|
||||
@@ -132,10 +133,10 @@ public class TypeUtil {
|
||||
} else {
|
||||
throw new IllegalArgumentException("mismatch class type");
|
||||
}
|
||||
// noinspection unchecked
|
||||
return (T) res;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T toObject(byte[] bytes, Type type) {
|
||||
if (bytes == null) {
|
||||
return null;
|
||||
@@ -182,7 +183,6 @@ public class TypeUtil {
|
||||
} else {
|
||||
throw new IllegalArgumentException("mismatch class type");
|
||||
}
|
||||
// noinspection unchecked
|
||||
return (T) res;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user