Search in sources :

Example 1 with ConsistencyCheckIncompleteException

use of org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException in project neo4j by neo4j.

the class CheckConsistencyCommand method execute.

@Override
public void execute(String[] args) throws IncorrectUsage, CommandFailed {
    final String database;
    final boolean verbose;
    final Optional<Path> additionalConfigFile;
    final Path reportDir;
    final Optional<Path> backupPath;
    final boolean checkGraph;
    final boolean checkIndexes;
    final boolean checkLabelScanStore;
    final boolean checkPropertyOwners;
    try {
        database = arguments.parse("database", args);
        backupPath = arguments.parseOptionalPath("backup", args);
        verbose = arguments.parseBoolean("verbose", args);
        additionalConfigFile = arguments.parseOptionalPath("additional-config", args);
        reportDir = arguments.parseOptionalPath("report-dir", args).orElseThrow(() -> new IllegalArgumentException("report-dir must be a valid path"));
    } catch (IllegalArgumentException e) {
        throw new IncorrectUsage(e.getMessage());
    }
    if (backupPath.isPresent()) {
        if (arguments.has("database", args)) {
            throw new IncorrectUsage("Only one of '--database' and '--backup' can be specified.");
        }
        if (!backupPath.get().toFile().isDirectory()) {
            throw new CommandFailed(format("Specified backup should be a directory: %s", backupPath.get()));
        }
    }
    Config config = loadNeo4jConfig(homeDir, configDir, database, loadAdditionalConfig(additionalConfigFile));
    try {
        // We can remove the loading from config file in 4.0
        if (arguments.has(CHECK_GRAPH, args)) {
            checkGraph = arguments.parseBoolean(CHECK_GRAPH, args);
        } else {
            checkGraph = ConsistencyCheckSettings.consistency_check_graph.from(config);
        }
        if (arguments.has(CHECK_INDEXES, args)) {
            checkIndexes = arguments.parseBoolean(CHECK_INDEXES, args);
        } else {
            checkIndexes = ConsistencyCheckSettings.consistency_check_indexes.from(config);
        }
        if (arguments.has(CHECK_LABEL_SCAN_STORE, args)) {
            checkLabelScanStore = arguments.parseBoolean(CHECK_LABEL_SCAN_STORE, args);
        } else {
            checkLabelScanStore = ConsistencyCheckSettings.consistency_check_label_scan_store.from(config);
        }
        if (arguments.has(CHECK_PROPERTY_OWNERS, args)) {
            checkPropertyOwners = arguments.parseBoolean(CHECK_PROPERTY_OWNERS, args);
        } else {
            checkPropertyOwners = ConsistencyCheckSettings.consistency_check_property_owners.from(config);
        }
    } catch (IllegalArgumentException e) {
        throw new IncorrectUsage(e.getMessage());
    }
    try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) {
        File storeDir = backupPath.map(Path::toFile).orElse(config.get(database_path));
        checkDbState(storeDir, config);
        ConsistencyCheckService.Result consistencyCheckResult = consistencyCheckService.runFullConsistencyCheck(storeDir, config, ProgressMonitorFactory.textual(System.err), FormattedLogProvider.toOutputStream(System.out), fileSystem, verbose, reportDir.toFile(), new CheckConsistencyConfig(checkGraph, checkIndexes, checkLabelScanStore, checkPropertyOwners));
        if (!consistencyCheckResult.isSuccessful()) {
            throw new CommandFailed(format("Inconsistencies found. See '%s' for details.", consistencyCheckResult.reportFile()));
        }
    } catch (ConsistencyCheckIncompleteException | IOException e) {
        throw new CommandFailed("Consistency checking failed." + e.getMessage(), e);
    }
}
Also used : Path(java.nio.file.Path) OptionalCanonicalPath(org.neo4j.commandline.arguments.common.OptionalCanonicalPath) CheckConsistencyConfig(org.neo4j.consistency.checking.full.CheckConsistencyConfig) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) CheckConsistencyConfig(org.neo4j.consistency.checking.full.CheckConsistencyConfig) Config(org.neo4j.kernel.configuration.Config) ConsistencyCheckIncompleteException(org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException) IOException(java.io.IOException) IncorrectUsage(org.neo4j.commandline.admin.IncorrectUsage) CommandFailed(org.neo4j.commandline.admin.CommandFailed) File(java.io.File)

Example 2 with ConsistencyCheckIncompleteException

use of org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException in project neo4j by neo4j.

the class ConsistencyCheckTool method run.

ConsistencyCheckService.Result run(String... args) throws ToolFailureException, IOException {
    Args arguments = Args.withFlags(VERBOSE).parse(args);
    File storeDir = determineStoreDirectory(arguments);
    Config tuningConfiguration = readConfiguration(arguments);
    boolean verbose = isVerbose(arguments);
    checkDbState(storeDir, tuningConfiguration);
    LogProvider logProvider = FormattedLogProvider.toOutputStream(System.out);
    try {
        return consistencyCheckService.runFullConsistencyCheck(storeDir, tuningConfiguration, ProgressMonitorFactory.textual(System.err), logProvider, fs, verbose, new CheckConsistencyConfig(tuningConfiguration));
    } catch (ConsistencyCheckIncompleteException e) {
        throw new ToolFailureException("Check aborted due to exception", e);
    }
}
Also used : LogProvider(org.neo4j.logging.LogProvider) FormattedLogProvider(org.neo4j.logging.FormattedLogProvider) Args(org.neo4j.helpers.Args) CheckConsistencyConfig(org.neo4j.consistency.checking.full.CheckConsistencyConfig) Config(org.neo4j.kernel.configuration.Config) CheckConsistencyConfig(org.neo4j.consistency.checking.full.CheckConsistencyConfig) ConsistencyCheckIncompleteException(org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException) File(java.io.File)

Example 3 with ConsistencyCheckIncompleteException

use of org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException in project neo4j by neo4j.

the class ConsistencyCheckService method runFullConsistencyCheck.

public Result runFullConsistencyCheck(File storeDir, Config config, ProgressMonitorFactory progressFactory, LogProvider logProvider, FileSystemAbstraction fileSystem, boolean verbose, File reportDir, CheckConsistencyConfig checkConsistencyConfig) throws ConsistencyCheckIncompleteException, IOException {
    Log log = logProvider.getLog(getClass());
    ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(fileSystem, config, PageCacheTracer.NULL, PageCursorTracerSupplier.NULL, logProvider.getLog(PageCache.class));
    PageCache pageCache = pageCacheFactory.getOrCreatePageCache();
    try {
        return runFullConsistencyCheck(storeDir, config, progressFactory, logProvider, fileSystem, pageCache, verbose, reportDir, checkConsistencyConfig);
    } finally {
        try {
            pageCache.close();
        } catch (Exception e) {
            log.error("Failure during shutdown of the page cache", e);
        }
    }
}
Also used : Log(org.neo4j.logging.Log) DuplicatingLog(org.neo4j.logging.DuplicatingLog) ConfiguringPageCacheFactory(org.neo4j.kernel.impl.pagecache.ConfiguringPageCacheFactory) PageCache(org.neo4j.io.pagecache.PageCache) IOException(java.io.IOException) ConsistencyCheckIncompleteException(org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException)

Example 4 with ConsistencyCheckIncompleteException

use of org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException in project neo4j by neo4j.

the class ConcurrentChangesOnEntitiesTest method assertDatabaseConsistent.

private void assertDatabaseConsistent() throws IOException {
    LogProvider logProvider = FormattedLogProvider.toOutputStream(System.out);
    try {
        ConsistencyCheckService.Result result = new ConsistencyCheckService().runFullConsistencyCheck(testDirectory.graphDbDir(), Config.defaults(), ProgressMonitorFactory.textual(System.err), logProvider, false);
        assertTrue(result.isSuccessful());
    } catch (ConsistencyCheckIncompleteException e) {
        fail(e.getMessage());
    }
}
Also used : LogProvider(org.neo4j.logging.LogProvider) FormattedLogProvider(org.neo4j.logging.FormattedLogProvider) ConsistencyCheckService(org.neo4j.consistency.ConsistencyCheckService) ConsistencyCheckIncompleteException(org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException)

Aggregations

ConsistencyCheckIncompleteException (org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException)4 File (java.io.File)2 IOException (java.io.IOException)2 CheckConsistencyConfig (org.neo4j.consistency.checking.full.CheckConsistencyConfig)2 Config (org.neo4j.kernel.configuration.Config)2 FormattedLogProvider (org.neo4j.logging.FormattedLogProvider)2 LogProvider (org.neo4j.logging.LogProvider)2 Path (java.nio.file.Path)1 CommandFailed (org.neo4j.commandline.admin.CommandFailed)1 IncorrectUsage (org.neo4j.commandline.admin.IncorrectUsage)1 OptionalCanonicalPath (org.neo4j.commandline.arguments.common.OptionalCanonicalPath)1 ConsistencyCheckService (org.neo4j.consistency.ConsistencyCheckService)1 Args (org.neo4j.helpers.Args)1 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)1 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)1 PageCache (org.neo4j.io.pagecache.PageCache)1 ConfiguringPageCacheFactory (org.neo4j.kernel.impl.pagecache.ConfiguringPageCacheFactory)1 DuplicatingLog (org.neo4j.logging.DuplicatingLog)1 Log (org.neo4j.logging.Log)1