@Override protected void run(final AnalysisJobBuilder analysisJobBuilder, final Action<AnalysisJobBuilder> executeAction, final AnalysisJobBuilderWindow analysisJobBuilderWindow) throws Exception { executeAction.run(analysisJobBuilder); } });
@Override default void accept(E t) { // delegate to run method and propagate exceptions if needed try { run(t); } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new RuntimeException(e); } }
@Override default void accept(E t) { // delegate to run method and propagate exceptions if needed try { run(t); } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new RuntimeException(e); } }
@Override protected boolean onWindowClosing() { final boolean close = super.onWindowClosing(); if (close) { if (_cancelCallback != null) { try { _cancelCallback.run(null); } catch (final Exception e) { logger.error("Cancelling file transfer threw exception", e); } } } return close; }
@Override public void run() { try { get(); } catch (RuntimeException e) { // do nothing, the exception will be handled via _error // below } if (_error != null && errorAction != null) { try { errorAction.run(_error); } catch (Exception e) { logger.error("Error handling action failed!", e); } } } });
@Override public void run() { try { get(); } catch (RuntimeException e) { // do nothing, the exception will be handled via _error // below } if (_error != null && errorAction != null) { try { errorAction.run(_error); } catch (Exception e) { logger.error("Error handling action failed!", e); } } } });
public final void flushBuffer() { int flushSize = _buffer.size(); if (flushSize == 0) { return; } logger.info("Flushing {} rows in write buffer", flushSize); final List<Object[]> copy = new ArrayList<Object[]>(flushSize); _buffer.drainTo(copy, flushSize); if (copy.isEmpty()) { // this can happen when there's a race going on for flushing the // buffer concurrently. return; } try { int batchNo = _batchNumber.incrementAndGet(); logger.info("Write batch no. {} starting", batchNo); _flushAction.run(copy); logger.info("Write batch no. {} finished", batchNo); } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new IllegalStateException(e); } } }
public final void flushBuffer() { final int flushSize = _buffer.size(); if (flushSize == 0) { return; } logger.info("Flushing {} rows in write buffer", flushSize); final List<Object[]> copy = new ArrayList<>(flushSize); _buffer.drainTo(copy, flushSize); if (copy.isEmpty()) { // this can happen when there's a race going on for flushing the // buffer concurrently. return; } try { final int batchNo = _batchNumber.incrementAndGet(); logger.info("Write batch no. {} starting", batchNo); _flushAction.run(copy); logger.info("Write batch no. {} finished", batchNo); } catch (final Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new IllegalStateException(e); } } }
@Override public void writeFile(final Action<OutputStream> writeCallback, final boolean append) { final Lock writeLock = _lock.writeLock(); writeLock.lock(); try { final FileOutputStream fileOutputStream; final OutputStream outputStream; try { fileOutputStream = new FileOutputStream(_file, append); outputStream = new BufferedOutputStream(fileOutputStream); } catch (final FileNotFoundException e) { throw new IllegalStateException(e); } try { if (writeCallback != null) { writeCallback.run(outputStream); } } catch (final Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new IllegalStateException("Error occurred while writing to file", e); } finally { FileHelper.safeClose(outputStream, fileOutputStream); } } finally { writeLock.unlock(); } }
@Override public void readFile(final Action<InputStream> readCallback) { final Lock readLock = _lock.readLock(); readLock.lock(); try { final FileInputStream fileInputStream; final InputStream inputStream; try { fileInputStream = new FileInputStream(_file); inputStream = new BufferedInputStream(fileInputStream); } catch (final FileNotFoundException e) { throw new IllegalStateException(e); } try { readCallback.run(inputStream); } catch (final Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new IllegalStateException("Error occurred while reading from file", e); } finally { FileHelper.safeClose(inputStream, fileInputStream); } } finally { readLock.unlock(); } }
public void run() { boolean successful = false; try { _publishAction.run(_rowPublisher); logger.debug("Publshing action finished!"); successful = true; } catch (Exception e) { _rowPublisher.failed(e); } if (successful) { _rowPublisher.finished(); } }; };
public void run() { boolean successful = false; try { _publishAction.run(_rowPublisher); logger.debug("Publshing action finished!"); successful = true; } catch (Exception e) { _rowPublisher.failed(e); } if (successful) { _rowPublisher.finished(); } }; };
@Override public final void append(Action<OutputStream> appendCallback) throws ResourceException { final OutputStream out = append(); try { appendCallback.run(out); } catch (Exception e) { throw new ResourceException(this, "Error occurred in append callback", e); } finally { FileHelper.safeClose(out); } }
@Override public final void write(Action<OutputStream> writeCallback) throws ResourceException { final OutputStream out = write(); try { writeCallback.run(out); } catch (Exception e) { throw new ResourceException(this, "Error occurred in write callback", e); } finally { FileHelper.safeClose(out); } }
@Override public final void append(Action<OutputStream> appendCallback) throws ResourceException { final OutputStream out = append(); try { appendCallback.run(out); } catch (Exception e) { throw new ResourceException(this, "Error occurred in append callback", e); } finally { FileHelper.safeClose(out); } }
@Override public final void read(Action<InputStream> readCallback) { final InputStream in = read(); try { readCallback.run(in); } catch (Exception e) { throw new ResourceException(this, "Error occurred in read callback", e); } finally { FileHelper.safeClose(in); } }
@Override public final void write(Action<OutputStream> writeCallback) throws ResourceException { final OutputStream out = write(); try { writeCallback.run(out); } catch (Exception e) { throw new ResourceException(this, "Error occurred in write callback", e); } finally { FileHelper.safeClose(out); } }
@Override public final void read(Action<InputStream> readCallback) { final InputStream in = read(); try { readCallback.run(in); } catch (Exception e) { throw new ResourceException(this, "Error occurred in read callback", e); } finally { FileHelper.safeClose(in); } }
@Override public void read(Action<InputStream> readCallback) throws ResourceException { try { InputStream in = _fileObject.getContent().getInputStream(); try { readCallback.run(in); } finally { FileHelper.safeClose(in); } } catch (Exception e) { throw new ResourceException(this, e); } }
@Override public void write(Action<OutputStream> writeCallback) throws ResourceException { try { FileContent content = _fileObject.getContent(); OutputStream out = content.getOutputStream(); try { writeCallback.run(out); } finally { FileHelper.safeClose(out); } } catch (Exception e) { throw new ResourceException(this, e); } }