List of usage examples for com.google.common.util.concurrent UncheckedExecutionException toString
public String toString()
From source file:com.streamsets.pipeline.stage.destination.kudu.KuduTarget.java
private void writeBatch(Batch batch) throws StageException { Multimap<String, Record> partitions = ELUtils.partitionBatchByExpression(tableNameEval, tableNameVars, tableNameTemplate, batch);// w w w .j a va 2 s. co m KuduSession session = Preconditions.checkNotNull(kuduSession, KUDU_SESSION); for (String tableName : partitions.keySet()) { Map<String, Record> keyToRecordMap = new HashMap<>(); Iterator<Record> it = partitions.get(tableName).iterator(); // if table doesn't exist, send records to the error handler and continue KuduTable table; try { table = kuduTables.getUnchecked(tableName); } catch (UncheckedExecutionException ex) { while (it.hasNext()) { errorRecordHandler.onError(new OnRecordErrorException(it.next(), Errors.KUDU_01, tableName)); } continue; } Optional<KuduRecordConverter> kuduRecordConverter = createKuduRecordConverter(table); if (!kuduRecordConverter.isPresent()) { throw new StageException(Errors.KUDU_11); } KuduRecordConverter recordConverter = kuduRecordConverter.get(); try { while (it.hasNext()) { try { Record record = it.next(); Insert insert = table.newInsert(); PartialRow row = insert.getRow(); recordConverter.convert(record, row); keyToRecordMap.put(insert.getRow().stringifyRowKey(), record); session.apply(insert); } catch (OnRecordErrorException onRecordError) { errorRecordHandler.onError(onRecordError); } } List<RowError> rowErrors = Collections.emptyList(); List<OperationResponse> responses = session.flush(); // can return null if (responses != null) { rowErrors = OperationResponse.collectErrors(responses); } // log ALL errors then process them for (RowError error : rowErrors) { LOG.warn(Errors.KUDU_03.getMessage(), error.toString()); } for (RowError error : rowErrors) { Insert insert = (Insert) error.getOperation(); // TODO SDC-2701 - support update on duplicate key if ("ALREADY_PRESENT".equals(error.getStatus())) { // duplicate row key String rowKey = insert.getRow().stringifyRowKey(); Record record = keyToRecordMap.get(rowKey); errorRecordHandler.onError(new OnRecordErrorException(record, Errors.KUDU_08, rowKey)); } else { throw new StageException(Errors.KUDU_03, error.toString()); } } } catch (Exception ex) { LOG.error(Errors.KUDU_03.getMessage(), ex.toString(), ex); throw throwStageException(ex); } } }