Search in sources :

Example 6 with BatchHelper

use of org.apache.storm.utils.BatchHelper in project storm by apache.

the class HBaseBolt method prepare.

@Override
public void prepare(Map<String, Object> map, TopologyContext topologyContext, OutputCollector collector) {
    super.prepare(map, topologyContext, collector);
    this.batchHelper = new BatchHelper(batchSize, collector);
}
Also used : BatchHelper(org.apache.storm.utils.BatchHelper)

Example 7 with BatchHelper

use of org.apache.storm.utils.BatchHelper in project storm by apache.

the class MongoInsertBolt method prepare.

@Override
public void prepare(Map<String, Object> topoConf, TopologyContext context, OutputCollector collector) {
    super.prepare(topoConf, context, collector);
    this.batchHelper = new BatchHelper(batchSize, collector);
}
Also used : BatchHelper(org.apache.storm.utils.BatchHelper)

Example 8 with BatchHelper

use of org.apache.storm.utils.BatchHelper in project storm by apache.

the class HiveBolt method prepare.

@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;
        this.batchHelper = new BatchHelper(options.getBatchSize(), collector);
        allWriters = new ConcurrentHashMap<HiveEndPoint, HiveWriter>();
        String timeoutName = "hive-bolt-%d";
        this.callTimeoutPool = Executors.newFixedThreadPool(1, new ThreadFactoryBuilder().setNameFormat(timeoutName).build());
        sendHeartBeat.set(true);
        heartBeatTimer = new Timer();
        setupHeartBeatTimer();
    } catch (Exception e) {
        LOG.warn("unable to make connection to hive ", e);
    }
}
Also used : Timer(java.util.Timer) HiveWriter(org.apache.storm.hive.common.HiveWriter) HiveUtils(org.apache.storm.hive.common.HiveUtils) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) IOException(java.io.IOException) BatchHelper(org.apache.storm.utils.BatchHelper)

Example 9 with BatchHelper

use of org.apache.storm.utils.BatchHelper in project storm by apache.

the class HiveBolt method prepare.

@Override
public void prepare(Map<String, Object> conf, TopologyContext topologyContext, OutputCollector collector) {
    try {
        tokenAuthEnabled = HiveUtils.isTokenAuthEnabled(conf);
        try {
            ugi = HiveUtils.authenticate(tokenAuthEnabled, options.getKerberosKeytab(), options.getKerberosPrincipal());
        } catch (HiveUtils.AuthenticationFailed ex) {
            LOG.error("Hive kerberos authentication failed " + ex.getMessage(), ex);
            throw new IllegalArgumentException(ex);
        }
        this.collector = collector;
        this.batchHelper = new BatchHelper(options.getBatchSize(), collector);
        allWriters = new ConcurrentHashMap<HiveEndPoint, HiveWriter>();
        String timeoutName = "hive-bolt-%d";
        this.callTimeoutPool = Executors.newFixedThreadPool(1, new ThreadFactoryBuilder().setNameFormat(timeoutName).build());
        sendHeartBeat.set(true);
        heartBeatTimer = new Timer(topologyContext.getThisTaskId() + "-hb-timer", true);
        setupHeartBeatTimer();
    } catch (Exception e) {
        LOG.warn("unable to make connection to hive ", e);
    }
}
Also used : Timer(java.util.Timer) HiveWriter(org.apache.storm.hive.common.HiveWriter) HiveUtils(org.apache.storm.hive.common.HiveUtils) HiveEndPoint(org.apache.hive.hcatalog.streaming.HiveEndPoint) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) StreamingException(org.apache.hive.hcatalog.streaming.StreamingException) IOException(java.io.IOException) BatchHelper(org.apache.storm.utils.BatchHelper)

Aggregations

BatchHelper (org.apache.storm.utils.BatchHelper)9 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)2 IOException (java.io.IOException)2 Timer (java.util.Timer)2 HiveUtils (org.apache.storm.hive.common.HiveUtils)2 HiveWriter (org.apache.storm.hive.common.HiveWriter)2 HiveEndPoint (org.apache.hive.hcatalog.streaming.HiveEndPoint)1 StreamingException (org.apache.hive.hcatalog.streaming.StreamingException)1 MQClientException (org.apache.rocketmq.client.exception.MQClientException)1 DefaultMQProducer (org.apache.rocketmq.client.producer.DefaultMQProducer)1