当前位置: 首页>>代码示例>>Java>>正文


Java FaultTolerance类代码示例

本文整理汇总了Java中eu.unifiedviews.helpers.dpu.extension.faulttolerance.FaultTolerance的典型用法代码示例。如果您正苦于以下问题:Java FaultTolerance类的具体用法?Java FaultTolerance怎么用?Java FaultTolerance使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FaultTolerance类属于eu.unifiedviews.helpers.dpu.extension.faulttolerance包,在下文中一共展示了FaultTolerance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadGraphStatements

import eu.unifiedviews.helpers.dpu.extension.faulttolerance.FaultTolerance; //导入依赖的package包/类
/**
 * Read all the statements in the given graph
 * @param graphUri URI of the graph
 * @throws DPUException
 */
private void loadGraphStatements(final URI graphUri) throws DPUException {
    faultTolerance.execute(rdfInput, new FaultTolerance.ConnectionAction() {
        @Override
        public void action(RepositoryConnection connection) throws Exception {
            RepositoryResult<Statement> repositoryResult = connection.getStatements(null, null, null, false, graphUri);
            try {
                rdfStringWriter.flush();
                rdfWriter.startRDF();
                while (repositoryResult.hasNext()) {
                    if (ctx.canceled()) {
                        throw ContextUtils.dpuExceptionCancelled(ctx);
                    }
                    rdfWriter.handleStatement(repositoryResult.next());
                }
                rdfWriter.endRDF();
            } catch (RDFHandlerException e) {
                throw new DPUException("Encountered an exception when parsing RDF statements from graph: " + graphUri.stringValue(), e);
            }
        }
    });
}
 
开发者ID:poolparty-team,项目名称:PP-UnifiedViews-Plugins,代码行数:27,代码来源:RdfHttpLoader.java

示例2: loadGraphStatements

import eu.unifiedviews.helpers.dpu.extension.faulttolerance.FaultTolerance; //导入依赖的package包/类
/**
 * Read all the statements in the given graph
 * @param graphUri URI of the graph
 * @throws DPUException
 */
private void loadGraphStatements(final URI graphUri) throws DPUException {
    graphStatements = new HashSet<>();
    faultTolerance.execute(rdfInput, new FaultTolerance.ConnectionAction() {
        @Override
        public void action(RepositoryConnection connection) throws Exception {
            RepositoryResult<Statement> repositoryResult = connection.getStatements(null, null, null, false, graphUri);
            graphStatements.clear();
            while (repositoryResult.hasNext()) {
                if (ctx.canceled()) {
                    throw ContextUtils.dpuExceptionCancelled(ctx);
                }
                graphStatements.add(repositoryResult.next());
            }

        }
    });
}
 
开发者ID:poolparty-team,项目名称:PP-UnifiedViews-Plugins,代码行数:23,代码来源:ConceptExtractor.java

示例3: loadFilenameUriMappings

import eu.unifiedviews.helpers.dpu.extension.faulttolerance.FaultTolerance; //导入依赖的package包/类
/**
 * Read filename to URI mappings from the given graph
 * @param graphUri URI of the graph
 * @throws DPUException
 */
private void loadFilenameUriMappings(final URI graphUri) throws DPUException {
    filenameUriMappings = new HashMap<>();
    faultTolerance.execute(rdfInput, new FaultTolerance.ConnectionAction() {
        @Override
        public void action(RepositoryConnection connection) throws Exception {
            RepositoryResult<Statement> repositoryResult = connection.getStatements(null, null, null, false, graphUri);
            filenameUriMappings.clear();
            while (repositoryResult.hasNext()) {
                if (ctx.canceled()) {
                    throw ContextUtils.dpuExceptionCancelled(ctx);
                }
                Statement filenameStmt = repositoryResult.next();
                filenameUriMappings.put(filenameStmt.getObject().stringValue(), filenameStmt.getSubject().stringValue());
            }

        }
    });
}
 
开发者ID:poolparty-team,项目名称:PP-UnifiedViews-Plugins,代码行数:24,代码来源:ConceptExtractor.java

示例4: executeInsert

import eu.unifiedviews.helpers.dpu.extension.faulttolerance.FaultTolerance; //导入依赖的package包/类
private void executeInsert(final String query, final List<RDFDataUnit.Entry> source,
        final RDFDataUnit.Entry target) throws DPUException {
    LOG.info("QUERY: {}", query);
    // Prepare SPARQL update query.
    final SparqlUtils.SparqlUpdateObject updateQuery = faultTolerance.execute(
            new FaultTolerance.ActionReturn<SparqlUtils.SparqlUpdateObject>() {

                @Override
                public SparqlUtils.SparqlUpdateObject action() throws Exception {
                    return SparqlUtils.createInsert(query, source, target);
                }
            }, "dpu.error.sparql.preparation");

    // Execute SPARQL ie. copy metadata that match given conditions.
    faultTolerance.execute(outFilesData, new FaultTolerance.ConnectionAction() {

        @Override
        public void action(RepositoryConnection connection) throws Exception {
            SparqlUtils.execute(connection, updateQuery);
        }
    }, "dpu.error.sparql.execution");
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:23,代码来源:Renamer.java

示例5: executeDeleteInsert

import eu.unifiedviews.helpers.dpu.extension.faulttolerance.FaultTolerance; //导入依赖的package包/类
private void executeDeleteInsert(final String query, final List<RDFDataUnit.Entry> source,
        final RDFDataUnit.Entry target) throws DPUException {
    LOG.info("QUERY: {}", query);
    // Prepare SPARQL update query.
    final SparqlUtils.SparqlUpdateObject updateQuery = faultTolerance.execute(
            new FaultTolerance.ActionReturn<SparqlUtils.SparqlUpdateObject>() {

                @Override
                public SparqlUtils.SparqlUpdateObject action() throws Exception {
                    return SparqlUtils.createDelete(query, source, target);
                }
            }, "dpu.error.sparql.preparation");

    // Execute SPARQL ie. copy metadata that match given conditions.
    faultTolerance.execute(outFilesData, new FaultTolerance.ConnectionAction() {

        @Override
        public void action(RepositoryConnection connection) throws Exception {
            SparqlUtils.execute(connection, updateQuery);
        }
    }, "dpu.error.sparql.execution");
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:23,代码来源:Renamer.java

示例6: XsltExecutor

import eu.unifiedviews.helpers.dpu.extension.faulttolerance.FaultTolerance; //导入依赖的package包/类
public XsltExecutor(XsltConfig_V2 config,
        BlockingQueue<Task> taskQueue, FaultTolerance faultTolerance, UserExecContext ctx,
        Integer totalFileCounter)
        throws DPUException {
    LOG.info("New executor created!");
    this.proc = new Processor(false);
    // register UUID extension function
    proc.registerExtensionFunction(UUIDGenerator.getInstance());
    this.compiler = proc.newXsltCompiler();
    try {
        this.executable = compiler.compile(
                new StreamSource(new StringReader(config.getXsltTemplate())));
    } catch (SaxonApiException ex) {
        throw ContextUtils.dpuException(ctx, ex, "xslt.dpu.executor.errors.xsltCompile");
    }
    this.config = config;
    this.taskQueue = taskQueue;
    this.ctx = ctx;
    this.totalFileCounter = totalFileCounter;
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:21,代码来源:XsltExecutor.java

示例7: scanDirectory

import eu.unifiedviews.helpers.dpu.extension.faulttolerance.FaultTolerance; //导入依赖的package包/类
/**
 * Scan given directory for files and add then to {@link #outFilesData}.
 *
 * @param directory
 * @throws DPUException
 */
private void scanDirectory(File directory, String pathPrefix) throws DPUException {
    final Path directoryPath = directory.toPath();
    final Iterator<File> iter = FileUtils.iterateFiles(directory, null, true);
    while (iter.hasNext()) {
        final File newFile = iter.next();
        final String relativePath = directoryPath.relativize(newFile.toPath()).toString();
        final String newFileRelativePath;
        if (config.isNotPrefixed()) {
            newFileRelativePath = relativePath;
        } else {
            newFileRelativePath = pathPrefix + "/" + relativePath;
        }
        // Add file.
        faultTolerance.execute(new FaultTolerance.Action() {

            @Override
            public void action() throws Exception {
                FilesDataUnitUtils.addFile(outFilesData, newFile, newFileRelativePath);
            }
        }, "unzipper.error.file.add");
    }
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:29,代码来源:UnZipper.java

示例8: prepareUsingClause

import eu.unifiedviews.helpers.dpu.extension.faulttolerance.FaultTolerance; //导入依赖的package包/类
/**
 * @param entries
 *            List of entries to use.
 * @return Using clause for SPARQL insert, based on input graphs.
 * @throws DPUException
 */
protected String prepareUsingClause(final List<RDFDataUnit.Entry> entries) throws DPUException {
    return faultTolerance.execute(new FaultTolerance.ActionReturn<String>() {

        @Override
        public String action() throws Exception {
            final StringBuilder usingClause = new StringBuilder();
            for (RDFDataUnit.Entry entry : entries) {
                usingClause.append("USING <");
                try {
                    usingClause.append(entry.getDataGraphURI().stringValue());
                } catch (DataUnitException ex) {
                    throw ContextUtils.dpuException(ctx, ex, "SparqlConstruct.execute.exception.internal");
                }
                usingClause.append("> \n");
            }
            return usingClause.toString();
        }

    });
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:27,代码来源:SparqlConstruct.java

示例9: getTriplesCount

import eu.unifiedviews.helpers.dpu.extension.faulttolerance.FaultTolerance; //导入依赖的package包/类
/**
 * @param dataUnit
 * @param entries
 * @return Number of triples in given entries.
 */
protected Long getTriplesCount(final RDFDataUnit dataUnit, final IRI[] graphs)
        throws DPUException {
    return faultTolerance.execute(new FaultTolerance.ActionReturn<Long>() {

        @Override
        public Long action() throws Exception {
            RepositoryConnection connection = null;
            Long size = 0l;
            try {
                connection = dataUnit.getConnection();
                size = connection.size(graphs);
            } finally {
                if (connection != null) {
                    connection.close();
                }
            }
            return size;
        }

    });
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:27,代码来源:SparqlConstruct.java

示例10: generateGraphFile

import eu.unifiedviews.helpers.dpu.extension.faulttolerance.FaultTolerance; //导入依赖的package包/类
/**
 * Check if file graph should be generated and if so, then generate new graph file.
 * 
 * @param rdfFile
 * @param graphName
 *            Name of the graph, that will be written into .graph file.
 * @throws DPUException
 */
private void generateGraphFile(final FilesDataUnit.Entry rdfFile, String graphName) throws DPUException {
    final FilesDataUnit.Entry graphFileEntry = faultTolerance.execute(new FaultTolerance.ActionReturn<FilesDataUnit.Entry>() {

        @Override
        public FilesDataUnit.Entry action() throws Exception {
            final String rdfFilePath = MetadataUtils.get(inRdfData, rdfFile, FilesVocabulary.UV_VIRTUAL_PATH);
            return FilesDataUnitUtils.createFile(outFilesData, rdfFilePath + ".graph");
        }
    });
    try {
        FileUtils.writeStringToFile(FaultToleranceUtils.asFile(faultTolerance, graphFileEntry), graphName);
    } catch (IOException ex) {
        throw ContextUtils.dpuException(ctx, ex, "rdfToFiles.error.graphFile");
    }
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:24,代码来源:RdfToFiles.java

示例11: setOutput

import eu.unifiedviews.helpers.dpu.extension.faulttolerance.FaultTolerance; //导入依赖的package包/类
/**
 * Set given graphs as current output.
 * 
 * @param entries
 * @return
 * @throws cz.cuni.mff.xrg.uv.boost.serialization.rdf.SimpleRdfException
 */
public WritableSimpleRdf setOutput(final List<RDFDataUnit.Entry> entries)
        throws SimpleRdfException, DPUException {
    // Flush buffer first.
    flushBuffer();
    if (faultTolerance == null) {
        setOutputInner(entries);
    } else {
        faultTolerance.execute(new FaultTolerance.Action() {

            @Override
            public void action() throws Exception {
                setOutputInner(entries);
            }
        });
    }
    return this;
}
 
开发者ID:UnifiedViews,项目名称:Plugin-DevEnv,代码行数:25,代码来源:WritableSimpleRdf.java

示例12: createDefaultWriteGraph

import eu.unifiedviews.helpers.dpu.extension.faulttolerance.FaultTolerance; //导入依赖的package包/类
/**
 * Create and set new default output graph. Fixed symbolic name is used for output graph.
 * 
 * @throws SimpleRdfException
 * @throws DPUException
 */
private void createDefaultWriteGraph() throws SimpleRdfException, DPUException {
    LOG.info("Default output graph used.");
    final IRI writeGraphUri;
    if (faultTolerance == null) {
        try {
            writeGraphUri = writableDataUnit.addNewDataGraph(DEFAULT_SYMBOLIC_NAME);
        } catch (DataUnitException ex) {
            throw new SimpleRdfException("Failed to add new graph.", ex);
        }
    } else {
        writeGraphUri = faultTolerance.execute(new FaultTolerance.ActionReturn<IRI>() {

            @Override
            public IRI action() throws Exception {
                return writableDataUnit.addNewDataGraph(DEFAULT_SYMBOLIC_NAME);
            }
        });
    }
    writeContext.add(writeGraphUri);
}
 
开发者ID:UnifiedViews,项目名称:Plugin-DevEnv,代码行数:27,代码来源:WritableSimpleRdf.java

示例13: getValueFactory

import eu.unifiedviews.helpers.dpu.extension.faulttolerance.FaultTolerance; //导入依赖的package包/类
/**
 * Cache result. After first successful call does not fail.
 * 
 * @return
 * @throws DataUnitException
 */
public ValueFactory getValueFactory() throws DPUException {
    if (faultTolerance == null) {
        try {
            return getValueFactoryInner();
        } catch (DataUnitException ex) {
            throw new DPUException(ex);
        }
    } else {
        return faultTolerance.execute(new FaultTolerance.ActionReturn<ValueFactory>() {

            @Override
            public ValueFactory action() throws Exception {
                return getValueFactoryInner();
            }

        });
    }
}
 
开发者ID:UnifiedViews,项目名称:Plugin-DevEnv,代码行数:25,代码来源:SimpleRdf.java

示例14: innerExecute

import eu.unifiedviews.helpers.dpu.extension.faulttolerance.FaultTolerance; //导入依赖的package包/类
@Override
protected void innerExecute() throws DPUException {
    final List<RDFDataUnit.Entry> source = faultTolerance.execute(new FaultTolerance.ActionReturn<List<RDFDataUnit.Entry>>() {

        @Override
        public List<RDFDataUnit.Entry> action() throws Exception {
            return DataUnitUtils.getMetadataEntries(input);
        }
    });
    final RDFDataUnit.Entry target = faultTolerance.execute(new FaultTolerance.ActionReturn<RDFDataUnit.Entry>() {

        @Override
        public RDFDataUnit.Entry action() throws Exception {
            return DataUnitUtils.getWritableMetadataEntry(output);
        }
    });
    // Use query to copy data.
    faultTolerance.execute(input, new FaultTolerance.ConnectionAction() {

        @Override
        public void action(RepositoryConnection connection) throws Exception {
            final SparqlUtils.SparqlUpdateObject update = SparqlUtils.createInsert(QUERY_COPY, source, target);
            // Copy data.
            SparqlUtils.execute(connection, update);

        }
    });

}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:30,代码来源:RdfMerger.java

示例15: innerExecute

import eu.unifiedviews.helpers.dpu.extension.faulttolerance.FaultTolerance; //导入依赖的package包/类
@Override
protected void innerExecute() throws DPUException {
    final List<FilesDataUnit.Entry> files = FaultToleranceUtils.getEntries(faultTolerance, inFilesData, FilesDataUnit.Entry.class);
    // Prepare zip file.
    final String zipSymbolicName = config.getZipFile();
    final FilesDataUnit.Entry output = faultTolerance.execute(new FaultTolerance.ActionReturn<FilesDataUnit.Entry>() {

        @Override
        public FilesDataUnit.Entry action() throws Exception {
            return FilesDataUnitUtils.createFile(outFilesData, zipSymbolicName);
        }
    });
    
    final Resource resource = new Resource();
    resource.setFormat("application/zip");
    resource.setMimetype("application/zip");
    resource.setCreated(new Date());
    resource.setLast_modified(new Date());
    // TODO Check if this works with fault tolerance wrap.
    faultTolerance.execute(new FaultTolerance.Action() {

        @Override
        public void action() throws Exception {
            ResourceHelpers.setResource(outFilesData, zipSymbolicName, resource);
        }
    });

    // Create zip file - this does not
    final File outputFile = FaultToleranceUtils.asFile(faultTolerance, output);
    zipFiles(outputFile, files);
}
 
开发者ID:UnifiedViews,项目名称:Plugins,代码行数:32,代码来源:Zipper.java


注:本文中的eu.unifiedviews.helpers.dpu.extension.faulttolerance.FaultTolerance类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。