@Override public boolean delete( String basePath, ResourcePattern resourcePattern, boolean recursive, Counter counter) throws IOException, InterruptedException { return core.delete(basePath, resourcePattern, recursive, counter); }
@Override public void close() throws IOException { output.close(); try { dataSource.commitAttemptOutput(outputContext); dataSource.cleanupAttemptOutput(outputContext); dataSource.commitTransactionOutput(outputContext.getTransactionContext()); dataSource.cleanupTransactionOutput(outputContext.getTransactionContext()); } catch (InterruptedException e) { throw (IOException) new InterruptedIOException("interrupted").initCause(e); //$NON-NLS-1$ } } };
@Override public <T> List<DirectInputFragment> findInputFragments( DataDefinition<T> definition, String basePath, ResourcePattern resourcePattern) throws IOException, InterruptedException { return core.findInputFragments(definition, basePath, resourcePattern); }
new Counter()); ds.setupTransactionOutput(txContext); ds.setupAttemptOutput(aContext); try (ModelOutput<StringBuilder> output = ds.openOutput( aContext, SimpleDataDefinition.newInstance(StringBuilder.class, new MockFormat()), output.write(new StringBuilder("Hello, world!")); ds.commitAttemptOutput(aContext); ds.cleanupAttemptOutput(aContext);
dataSource.setupTransactionOutput(outputContext.getTransactionContext()); dataSource.setupAttemptOutput(outputContext); Counter counter = new Counter(); ModelOutput<T> output = dataSource.openOutput(outputContext, definition, basePath, outputPath, counter); return new ModelOutput<T>() { @Override
@Override public <T> ModelInput<T> openInput( DataDefinition<T> definition, DirectInputFragment fragment, Counter counter) throws IOException, InterruptedException { return core.openInput(definition, fragment, counter); }
assert dataSource != null; List<DirectInputFragment> fragments = dataSource.findInputFragments(definition, path.componentPath, path.pattern); if (fragments.isEmpty()) { String id = repo.getRelatedId(group.containerPath); String pathString = dataSource.path(path.componentPath, path.pattern); if (path.optional) { LOG.info(MessageFormat.format(
@Override public <T> ModelOutput<T> openOutput( OutputAttemptContext context, DataDefinition<T> definition, String basePath, String resourcePath, Counter counter) throws IOException, InterruptedException { return core.openOutput(context, definition, basePath, resourcePath, counter); }
static List<ResourceInfo> list(DirectIoPath path) { LOG.debug("listing: {} ({})", path, path.getBarePath()); try { if (path.isComponentRoot()) { return Collections.singletonList(new ResourceInfo( path.getSource().getId(), path.getSource().getEntity().path(path.getComponentPath().getPathString()), true)); } else if (path.getResourcePattern().isPresent()) { return path.getSource().getEntity().list( path.getComponentPath().getPathString(), path.getResourcePattern().get(), new Counter()); } else { return path.getSource().getEntity().list( BasePath.EMPTY.getPathString(), path.getComponentPath().asFilePattern(), new Counter()); } } catch (IOException | InterruptedException e) { throw new CommandExecutionException(MessageFormat.format( "error occurred while resolving path: {0} ({1})", path, path.getBarePath()), e); } } }
@Override public List<ResourceInfo> list( String basePath, ResourcePattern resourcePattern, Counter counter) throws IOException, InterruptedException { return core.list(basePath, resourcePattern, counter); }
@Override public void commitAttemptOutput(OutputAttemptContext context) throws IOException, InterruptedException { core.commitAttemptOutput(context); }
@Override public void setupAttemptOutput(OutputAttemptContext context) throws IOException, InterruptedException { core.setupAttemptOutput(context); }
@Override public void setupTransactionOutput(OutputTransactionContext context) throws IOException, InterruptedException { core.setupTransactionOutput(context); }
@Override public void cleanupAttemptOutput(OutputAttemptContext context) throws IOException, InterruptedException { core.cleanupAttemptOutput(context); }
DirectDataSource datasource = repo.getRelatedDataSource(containerPath); OutputTransactionContext context = HadoopDataSourceUtil.createContext(executionId, datasourceId); datasource.commitTransactionOutput(context); datasource.cleanupTransactionOutput(context); } catch (IOException e) { succeed = false;
@Override public void cleanupTransactionOutput(OutputTransactionContext context) throws IOException, InterruptedException { core.cleanupTransactionOutput(context); }
private ModelInput<T> prepare() throws IOException { if (fragments.hasNext()) { DirectInputFragment f = fragments.next(); try { return dataSource.openInput(definition, f, counter); } catch (InterruptedException e) { throw (IOException) new InterruptedIOException().initCause(e); } } else { return null; } }
@Override public <T> ModelOutput<T> openOutput( OutputAttemptContext context, DataDefinition<T> definition, String basePath, String resourcePath, Counter counter) throws IOException, InterruptedException { ModelOutput<T> output = entity.openOutput(context, definition, basePath, resourcePath, counter); return new WrappedModelOutput<>(output, heartbeat, counter); }
@Override public List<ResourceInfo> list( String basePath, ResourcePattern resourcePattern, Counter counter) throws IOException, InterruptedException { heartbeat.register(counter); try { return entity.list(basePath, resourcePattern, counter); } finally { heartbeat.unregister(counter); } }
@Override public void commitAttemptOutput(OutputAttemptContext context) throws IOException, InterruptedException { if (context == null) { throw new IllegalArgumentException("context must not be null"); //$NON-NLS-1$ } Counter counter = context.getCounter(); heartbeat.register(counter); try { entity.commitAttemptOutput(context); } finally { heartbeat.unregister(counter); } }