Github user revans2 commented on a diff in the pull request:
https://github.com/apache/storm/pull/871#discussion_r49201617
--- Diff:
external/storm-hive/src/main/java/org/apache/storm/hive/bolt/HiveBolt.java ---
@@ -25,75 +26,40 @@
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.utils.TupleUtils;
import backtype.storm.Config;
+import org.apache.storm.hive.common.HiveConnector;
import org.apache.storm.hive.common.HiveWriter;
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.hive.hcatalog.streaming.*;
import org.apache.storm.hive.common.HiveOptions;
import org.apache.storm.hive.common.HiveUtils;
-import org.apache.hadoop.security.UserGroupInformation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
-import java.util.ArrayList;
import java.util.Map;
-import java.util.HashMap;
-import java.util.Timer;
-import java.util.TimerTask;
-import java.util.Map.Entry;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.List;
import java.util.LinkedList;
-import java.io.IOException;
public class HiveBolt extends BaseRichBolt {
private static final Logger LOG =
LoggerFactory.getLogger(HiveBolt.class);
private OutputCollector collector;
private HiveOptions options;
- private ExecutorService callTimeoutPool;
- private transient Timer heartBeatTimer;
- private Boolean kerberosEnabled = false;
- private AtomicBoolean timeToSendHeartBeat = new AtomicBoolean(false);
- private UserGroupInformation ugi = null;
- HashMap<HiveEndPoint, HiveWriter> allWriters;
+ private HiveConnector hiveConnector;
private List<Tuple> tupleBatch;
+ transient CountMetric serializationErrorMetric;
public HiveBolt(HiveOptions options) {
this.options = options;
tupleBatch = new LinkedList<>();
+
}
@Override
public void prepare(Map conf, TopologyContext topologyContext,
OutputCollector collector) {
try {
- if(options.getKerberosPrincipal() == null &&
options.getKerberosKeytab() == null) {
- kerberosEnabled = false;
- } else if(options.getKerberosPrincipal() != null &&
options.getKerberosKeytab() != null) {
- kerberosEnabled = true;
- } else {
- throw new IllegalArgumentException("To enable Kerberos,
need to set both KerberosPrincipal " +
- " & KerberosKeytab");
- }
-
- if (kerberosEnabled) {
- try {
- ugi =
HiveUtils.authenticate(options.getKerberosKeytab(),
options.getKerberosPrincipal());
- } catch(HiveUtils.AuthenticationFailed ex) {
- LOG.error("Hive Kerberos authentication failed " +
ex.getMessage(), ex);
- throw new IllegalArgumentException(ex);
- }
- }
this.collector = collector;
- allWriters = new HashMap<HiveEndPoint,HiveWriter>();
- String timeoutName = "hive-bolt-%d";
- this.callTimeoutPool = Executors.newFixedThreadPool(1,
- new
ThreadFactoryBuilder().setNameFormat(timeoutName).build());
- heartBeatTimer = new Timer();
- setupHeartBeatTimer();
-
+ this.hiveConnector = new HiveConnector(this.options);
+ this.hiveConnector.configure();
+ this.serializationErrorMetric = new CountMetric();
+
topologyContext.registerMetric("hive_serialization_error_count",
serializationErrorMetric, 0);
--- End diff --
Not really sure what registering a metric that is reported every 0 seconds
does.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---