コード例 #1
0
ファイル: HiveDump.java プロジェクト: dbist/kafka-storm-hive
 public void close() {
   try {
     connection.close();
   } catch (Exception ex) {
     LOG.log(Level.WARNING, "error closing connection to Hive");
   }
 }
コード例 #2
0
ファイル: HiveDump.java プロジェクト: dbist/kafka-storm-hive
  public void persistRecord(List<Tuple> tuples) {
    TransactionBatch txnBatch = null;

    for (Tuple tuple : tuples) {
      try {
        StrictJsonWriter writer = new StrictJsonWriter(hiveEP);
        txnBatch = connection.fetchTransactionBatch(tuples.size(), writer);
        txnBatch.beginNextTransaction();

        byte[] record = tuple.getStringByField("json").getBytes();
        txnBatch.write(record);

      } catch (SerializationError ex) {
        LOG.log(Level.SEVERE, null, ex);
      } catch (StreamingException | InterruptedException ex) {
        LOG.log(Level.SEVERE, null, ex);
      }
      try {
        txnBatch.commit();
      } catch (StreamingException | InterruptedException ex) {
        LOG.log(Level.SEVERE, null, ex);
      }
    }
  }