This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new d8163d2 CAMEL-14805: Fixed tests
d8163d2 is described below
commit d8163d28293701e84b626b027eca11bd7dc6b570
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Mar 30 11:44:01 2020 +0200
CAMEL-14805: Fixed tests
---
.../camel/component/hbase/HBaseComponent.java | 15 ++++----
.../camel/component/hbase/HBaseEndpoint.java | 40 +++++-----------------
.../camel/component/hbase/HBaseProducer.java | 3 --
3 files changed, 15 insertions(+), 43 deletions(-)
diff --git
a/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseComponent.java
b/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseComponent.java
index 60ed321..837856c 100644
---
a/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseComponent.java
+++
b/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseComponent.java
@@ -30,9 +30,6 @@ import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
-/**
- * Represents the component that manages {@link HBaseEndpoint}.
- */
@Component("hbase")
public class HBaseComponent extends DefaultComponent {
@@ -62,28 +59,30 @@ public class HBaseComponent extends DefaultComponent {
}
}
- connection = ConnectionFactory.createConnection(
- configuration,
- Executors.newFixedThreadPool(poolMaxSize)
- );
+ connection = ConnectionFactory.createConnection(configuration,
Executors.newFixedThreadPool(poolMaxSize));
}
@Override
protected void doStop() throws Exception {
if (connection != null) {
+ // this will also shutdown the thread pool
connection.close();
}
}
@Override
protected Endpoint createEndpoint(String uri, String remaining,
Map<String, Object> parameters) throws Exception {
- HBaseEndpoint endpoint = new HBaseEndpoint(uri, this, connection,
remaining);
+ HBaseEndpoint endpoint = new HBaseEndpoint(uri, this, remaining);
Map<String, Object> mapping =
PropertiesHelper.extractProperties(parameters, "row.");
endpoint.setRowMapping(mapping);
setProperties(endpoint, parameters);
return endpoint;
}
+ public Connection getConnection() {
+ return connection;
+ }
+
public Configuration getConfiguration() {
return configuration;
}
diff --git
a/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseEndpoint.java
b/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseEndpoint.java
index 1a3f612..365282d 100644
---
a/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseEndpoint.java
+++
b/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseEndpoint.java
@@ -32,10 +32,7 @@ import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriPath;
import org.apache.camel.support.DefaultEndpoint;
-import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.client.Connection;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.security.UserGroupInformation;
@@ -46,12 +43,9 @@ import org.apache.hadoop.security.UserGroupInformation;
@UriEndpoint(firstVersion = "2.10.0", scheme = "hbase", title = "HBase",
syntax = "hbase:tableName", label = "hadoop")
public class HBaseEndpoint extends DefaultEndpoint {
- private Configuration configuration;
- private final Connection connection;
- private HBaseAdmin admin;
-
@UriPath(description = "The name of the table") @Metadata(required = true)
private final String tableName;
+ private transient TableName tableNameObj;
@UriParam(label = "producer", defaultValue = "100")
private int maxResults = 100;
@UriParam
@@ -77,20 +71,13 @@ public class HBaseEndpoint extends DefaultEndpoint {
@UriParam(prefix = "row.", multiValue = true)
private Map<String, Object> rowMapping;
- /**
- * in the purpose of performance optimization
- */
- private byte[] tableNameBytes;
-
- public HBaseEndpoint(String uri, HBaseComponent component, Connection
connection, String tableName) {
+ public HBaseEndpoint(String uri, HBaseComponent component, String
tableName) {
super(uri, component);
this.tableName = tableName;
- this.connection = connection;
if (this.tableName == null) {
throw new IllegalArgumentException("Table name can not be null");
- } else {
- tableNameBytes = tableName.getBytes();
}
+ tableNameObj = TableName.valueOf(tableName);
}
@Override
@@ -106,20 +93,9 @@ public class HBaseEndpoint extends DefaultEndpoint {
return consumer;
}
- public Configuration getConfiguration() {
- return configuration;
- }
-
- public void setConfiguration(Configuration configuration) {
- this.configuration = configuration;
- }
-
- public HBaseAdmin getAdmin() {
- return admin;
- }
-
- public void setAdmin(HBaseAdmin admin) {
- this.admin = admin;
+ @Override
+ public HBaseComponent getComponent() {
+ return (HBaseComponent) super.getComponent();
}
public int getMaxResults() {
@@ -291,14 +267,14 @@ public class HBaseEndpoint extends DefaultEndpoint {
@Override
public Table run() {
try {
- return
connection.getTable(TableName.valueOf(tableNameBytes));
+ return
getComponent().getConnection().getTable(tableNameObj);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
});
} else {
- return connection.getTable(TableName.valueOf(tableNameBytes));
+ return getComponent().getConnection().getTable(tableNameObj);
}
}
diff --git
a/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseProducer.java
b/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseProducer.java
index 33e24a9..de8ca12 100644
---
a/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseProducer.java
+++
b/components/camel-hbase/src/main/java/org/apache/camel/component/hbase/HBaseProducer.java
@@ -103,9 +103,6 @@ public class HBaseProducer extends DefaultProducer {
/**
* Creates an HBase {@link Put} on a specific row, using a collection of
values (family/column/value pairs).
- *
- * @param hRow
- * @throws Exception
*/
private Put createPut(HBaseRow hRow) throws Exception {
ObjectHelper.notNull(hRow, "HBase row");