if (shouldRoll()) { closeWriter(); commitTransaction(); createWriter(); Channel channel = getChannel(); enterTransaction(channel); write(event); ((Flushable) writer).flush(); boolean committed = commitTransaction(); Preconditions.checkState(committed, "Tried to commit a batch when there was no transaction"); rollbackTransaction(); closeWriter(); } catch (EventDeliveryException ex) { LOG.warn("Error closing writer there may be temp files that need to"
@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(); }
if (writer == null) { try { this.writer = newWriter(login, target); } catch (DatasetException e) { "Cannot write to " + getName(), e); this.writer = newWriter(login, target); this.lastRolledMs = System.currentTimeMillis(); LOG.info("Rolled writer for " + getName()); Channel channel = getChannel(); Transaction transaction = null; try { this.datum = deserialize(event, reuseDatum ? datum : null);
@Override public synchronized void start() { this.lastRolledMillis = System.currentTimeMillis(); counter.start(); // signal that this sink is ready to process LOG.info("Started DatasetSink " + getName()); super.start(); }
Preconditions.checkArgument(allowedFormats().contains(format.getName()), "Unsupported format: " + format.getName());
@Override public synchronized void start() { this.lastRolledMs = System.currentTimeMillis(); counter.start(); // signal that this sink is ready to process LOG.info("Started DatasetSink " + getName()); super.start(); }
private DatasetWriter<GenericRecord> newWriter( final UserGroupInformation login, final URI uri) { View<GenericRecord> view = KerberosUtil.runPrivileged(login, new PrivilegedExceptionAction<Dataset<GenericRecord>>() { @Override public Dataset<GenericRecord> run() { return Datasets.load(uri); } }); DatasetDescriptor descriptor = view.getDataset().getDescriptor(); String formatName = descriptor.getFormat().getName(); Preconditions.checkArgument(allowedFormats().contains(formatName), "Unsupported format: " + formatName); Schema newSchema = descriptor.getSchema(); if (targetSchema == null || !newSchema.equals(targetSchema)) { this.targetSchema = descriptor.getSchema(); // target dataset schema has changed, invalidate all readers based on it readers.invalidateAll(); } this.reuseDatum = !("parquet".equals(formatName)); this.datasetName = view.getDataset().getName(); return view.newWriter(); }
if (shouldRoll()) { closeWriter(); commitTransaction(); createWriter(); Channel channel = getChannel(); enterTransaction(channel); write(event); ((Flushable) writer).flush(); boolean committed = commitTransaction(); Preconditions.checkState(committed, "Tried to commit a batch when there was no transaction"); rollbackTransaction(); closeWriter(); } catch (EventDeliveryException ex) { LOG.warn("Error closing writer there may be temp files that need to"
@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 synchronized void start() { this.lastRolledMillis = System.currentTimeMillis(); counter.start(); // signal that this sink is ready to process LOG.info("Started DatasetSink " + getName()); super.start(); }
Preconditions.checkArgument(allowedFormats().contains(format.getName()), "Unsupported format: " + format.getName());
@Override public synchronized void stop() { counter.stop(); if (writer != null) { // any write problems invalidate the writer, which is immediately closed writer.close(); this.writer = null; this.lastRolledMs = System.currentTimeMillis(); } // signal that this sink has stopped LOG.info("Stopped dataset sink: " + getName()); super.stop(); }