增加adapter assembly打包

This commit is contained in:
mcy
2018-10-25 10:05:05 +08:00
parent 30a11c75cb
commit 8dbf63e436
6 changed files with 59 additions and 25 deletions

View File

@@ -84,25 +84,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@@ -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);

View File

@@ -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;
}
}