Refine search
Channel channel = getChannel(); Transaction transaction = channel.getTransaction(); transaction.begin(); Event event = channel.take(); sinkCounter.incrementBatchUnderflowCount(); else sinkCounter.incrementBatchCompleteCount(); sinkCounter.incrementBatchEmptyCount(); sinkCounter.addToEventDrainAttemptCount(batch.size()); transaction.commit(); sinkCounter.addToEventDrainSuccessCount(batch.size()); transaction.rollback(); throw new EventDeliveryException(e);
@Override public synchronized void stop() { counter.stop(); try { // Close the writer and commit the transaction, but don't create a new // writer since we're stopping closeWriter(); commitTransaction(); } catch (EventDeliveryException ex) { rollbackTransaction(); LOG.warn("Closing the writer failed: " + ex.getLocalizedMessage()); LOG.debug("Exception follows.", ex); // We don't propogate the exception as the transaction would have been // rolled back and we can still finish stopping } // signal that this sink has stopped LOG.info("Stopped dataset sink: " + getName()); super.stop(); }
@Override public Status process() throws EventDeliveryException { Status result = Status.READY; Channel channel = getChannel(); Transaction transaction = channel.getTransaction(); Event event = null; try { transaction.begin(); event = channel.take(); if (event != null) { if (logger.isInfoEnabled()) { logger.info("Event: " + EventHelper.dumpEvent(event, maxBytesToLog)); } } else { // No event found, request back-off semantics from the sink runner result = Status.BACKOFF; } transaction.commit(); } catch (Exception ex) { transaction.rollback(); throw new EventDeliveryException("Failed to log event: " + event, ex); } finally { transaction.close(); } return result; } }
serializer.beforeClose(); outputStream.close(); sinkCounter.incrementConnectionClosedCount(); shouldRotate = false; } catch (IOException e) { sinkCounter.incrementConnectionFailedCount(); throw new EventDeliveryException("Unable to rotate file " + pathController.getCurrentFile() + " while delivering event", e); } finally { serializerType, serializerContext, outputStream); serializer.afterCreate(); sinkCounter.incrementConnectionCreatedCount(); throw new EventDeliveryException("Failed to open file " + pathController.getCurrentFile() + " while delivering event", e); Transaction transaction = channel.getTransaction(); Event event = null; Status result = Status.READY; transaction.commit(); transaction.rollback(); throw new EventDeliveryException("Failed to process transaction", ex);
Transaction transaction = channel.getTransaction(); transaction.begin(); boolean success = false; try { transaction.commit(); success = true; return Status.BACKOFF; } catch (Exception e) { sinkCounter.incrementEventWriteOrChannelFail(e); throw new EventDeliveryException(e); } finally { if (!success) { transaction.rollback(); transaction.close();
Event event = channel.take(); } catch (EventDeliveryException ex) { LOG.warn("Error closing writer there may be temp files that need to" + " be manually recovered: " + ex.getLocalizedMessage()); LOG.debug("Exception follows.", ex); throw new EventDeliveryException(th); counter.incrementBatchEmptyCount(); return Status.BACKOFF; } else if (processedEvents < batchSize) { counter.incrementBatchUnderflowCount(); } else { counter.incrementBatchCompleteCount();
private void throwIfClosed() throws EventDeliveryException { if (!isOpen) { throw new EventDeliveryException("Rpc Client is closed"); } }
private void handleTransactionFailure(Transaction txn) throws EventDeliveryException { if (maxConsecutiveFails > 0 && consecutiveHBaseFailures >= maxConsecutiveFails) { if (client != null) { shutdownHBaseClient(); } consecutiveHBaseFailures = 0; } try { txn.rollback(); } catch (Throwable e) { logger.error("Failed to commit transaction." + "Transaction rolled back.", e); if (e instanceof Error || e instanceof RuntimeException) { logger.error("Failed to commit transaction." + "Transaction rolled back.", e); Throwables.propagate(e); } else { logger.error("Failed to commit transaction." + "Transaction rolled back.", e); throw new EventDeliveryException("Failed to commit transaction." + "Transaction rolled back.", e); } } finally { txn.close(); } }
@Override public void run() { boolean success = false; int count = 0; try { while (!success && count < retries) { count++; try { logger.debug("Reporting a batch of {} events, try {}", events.length, count); createClient().appendBatch(Arrays.asList(events)); success = true; logger.debug("Successfully reported a batch of {} events", events.length); } catch (EventDeliveryException e) { logger.warn(e.getLocalizedMessage(), e); logger.warn("Will retry " + (retries - count) + " times"); } } } finally { if (!success) { logger.error("Could not submit events to Flume"); close(); } } } }
@Test (expected = TimeoutException.class) public void testTimeout() throws Throwable { try { src = new ThriftTestingSource(ThriftTestingSource.HandlerType.TIMEOUT.name(), port, ThriftRpcClient.COMPACT_PROTOCOL); client = (ThriftRpcClient) RpcClientFactory.getThriftInstance(props); insertEvents(client, 2); //2 events } catch (EventDeliveryException ex) { throw ex.getCause(); } }
Transaction transaction = channel.getTransaction(); Event event = null; long eventCounter = counterGroup.get("events.success"); transaction.begin(); int i = 0; for (i = 0; i < batchSize; i++) { event = channel.take(); if (++eventCounter % logEveryNEvents == 0) { logger.info("Null sink {} successful processed {} events.", getName(), eventCounter); transaction.commit(); counterGroup.addAndGet("events.success", (long) Math.min(batchSize, i)); counterGroup.incrementAndGet("transaction.success"); } catch (Exception ex) { transaction.rollback(); counterGroup.incrementAndGet("transaction.failed"); logger.error("Failed to deliver event. Exception follows.", ex); throw new EventDeliveryException("Failed to deliver event: " + event, ex); } finally { transaction.close();
serializer.beforeClose(); outputStream.close(); sinkCounter.incrementConnectionClosedCount(); shouldRotate = false; } catch (IOException e) { sinkCounter.incrementConnectionFailedCount(); throw new EventDeliveryException("Unable to rotate file " + pathController.getCurrentFile() + " while delivering event", e); } finally { serializerType, serializerContext, outputStream); serializer.afterCreate(); sinkCounter.incrementConnectionCreatedCount(); throw new EventDeliveryException("Failed to open file " + pathController.getCurrentFile() + " while delivering event", e); Transaction transaction = channel.getTransaction(); Event event = null; Status result = Status.READY; transaction.commit(); transaction.rollback(); throw new EventDeliveryException("Failed to process transaction", ex);
Transaction transaction = channel.getTransaction(); transaction.begin(); boolean success = false; try { transaction.commit(); success = true; return Status.BACKOFF; } catch (Exception e) { sinkCounter.incrementEventWriteOrChannelFail(e); throw new EventDeliveryException(e); } finally { if (!success) { transaction.rollback(); transaction.close();
Event event = channel.take(); } catch (EventDeliveryException ex) { LOG.warn("Error closing writer there may be temp files that need to" + " be manually recovered: " + ex.getLocalizedMessage()); LOG.debug("Exception follows.", ex); throw new EventDeliveryException(th); counter.incrementBatchEmptyCount(); return Status.BACKOFF; } else if (processedEvents < batchSize) { counter.incrementBatchUnderflowCount(); } else { counter.incrementBatchCompleteCount();
private void checkIfChannelExceptionAndThrow(Throwable e) throws EventDeliveryException { if (e instanceof ChannelException) { throw new EventDeliveryException("Error in processing transaction.", e); } else if (e instanceof Error || e instanceof RuntimeException) { Throwables.propagate(e); } throw new EventDeliveryException("Error in processing transaction.", e); }
private void handleTransactionFailure(Transaction txn) throws EventDeliveryException { if (maxConsecutiveFails > 0 && consecutiveHBaseFailures >= maxConsecutiveFails) { if (client != null) { shutdownHBaseClient(); } consecutiveHBaseFailures = 0; } try { txn.rollback(); } catch (Throwable e) { logger.error("Failed to commit transaction." + "Transaction rolled back.", e); if (e instanceof Error || e instanceof RuntimeException) { logger.error("Failed to commit transaction." + "Transaction rolled back.", e); Throwables.propagate(e); } else { logger.error("Failed to commit transaction." + "Transaction rolled back.", e); throw new EventDeliveryException("Failed to commit transaction." + "Transaction rolled back.", e); } } finally { txn.close(); } }
client.close(); client = null; LOG.error(e.getLocalizedMessage(), e); return false;
transaction = channel.getTransaction(); transaction.begin(); long beginTime = System.currentTimeMillis(); while (true) { Event event = channel.take(); if (event != null) { events.add(event); sinkCounter.incrementBatchEmptyCount(); transaction.rollback(); return Status.BACKOFF; sinkCounter.addToEventDrainAttemptCount(events.size()); transaction.rollback(); return Status.BACKOFF; } else { transaction.commit(); sinkCounter.addToEventDrainSuccessCount(events.size()); } catch (Exception ex) { log.error("Failed to rollback transaction", ex); throw new EventDeliveryException("Failed to rollback transaction", ex);
long processedEvents = 0; transaction = channel.getTransaction(); transaction.begin(); event = channel.take(); throw new EventDeliveryException("Non integer partition id specified", ex); } catch (Exception ex) { throw new EventDeliveryException("Could not send event", ex); transaction.commit(); try { kafkaFutures.clear(); transaction.rollback(); counter.incrementRollbackCount(); } catch (Exception e) { throw new EventDeliveryException(errorMsg, ex); } finally { if (transaction != null) {
@Override public void handle(Event event, Throwable cause) throws EventDeliveryException { LOG.error("Event delivery failed: " + cause.getLocalizedMessage()); LOG.debug("Exception follows.", cause); throw new EventDeliveryException(cause); }