Spark streaming: HBase connection is closed when using hbaseMapPartitions

in my Spark streaming app I am using HBaseContext to put some values ​​in HBase, one input operation for each processed message.

If I use hbaseForeachPartitions everything is fine.

 dStream
  .hbaseForeachPartition(
    hbaseContext,
    (iterator, connection) => {
      val table = connection.getTable("namespace:table")
      // putHBase is external function in the same Scala object
      val results = iterator.flatMap(packet => putHBaseAndOther(packet))
      table.close()
      results
    }
 )

      

Instead of hbaseMapPartitions, the HBase connection is closed.

 dStream
  .hbaseMapPartition(
    hbaseContext,
    (iterator, connection) => {
      val table = connection.getTable("namespace:table")
      // putHBase is external function in the same Scala object
      val results = iterator.flatMap(packet => putHBaseAndOther(packet))
      table.close()
      results
    }
 )

      

Can anyone please explain to me why?

+3
hbase streaming apache-spark


source to share


No one has answered this question yet

Check out similar questions:

3
Reading Hbase data in Spark Streaming
2
Spark Streaming: Using PairRDD.saveAsNewHadoopDataset Function to Save Data to HBase
1
Problem: Scala code in Spark wrapper to fetch data from Hbase
1
Inconsistency and abrupt behavior of Spark filter, current timestamp, and HBase custom receiver in Spark structured streaming
1
Save Kafka messages to HBase via Spark. The session is never closed
1
Error while reading hbase inside spark rdd foreach action
1
HBase Spark Connection Options [Java]
1
Spark Streaming in HBase with filtering logic
1
Correctly close Hbase resources while working with spark flow
0
Stream-to-stream stream - parallelization



All Articles
Loading...
X
Show
Funny
Dev
Pics