Exemplo n.º 1
0
 public void close() {
   try {
     connection.close();
   } catch (Exception ex) {
     LOG.log(Level.WARNING, "error closing connection to Hive");
   }
 }
Exemplo n.º 2
0
  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);
      }
    }
  }