Search in sources :

Example 71 with Config

use of org.neo4j.kernel.configuration.Config in project neo4j by neo4j.

the class ConsistencyCheckToolTest method passesOnConfigurationIfProvided.

@Test
public void passesOnConfigurationIfProvided() throws Exception {
    // given
    File storeDir = storeDirectory.directory();
    File configFile = storeDirectory.file("neo4j.conf");
    Properties properties = new Properties();
    properties.setProperty(ConsistencyCheckSettings.consistency_check_property_owners.name(), "true");
    properties.store(new FileWriter(configFile), null);
    String[] args = { storeDir.getPath(), "-config", configFile.getPath() };
    ConsistencyCheckService service = mock(ConsistencyCheckService.class);
    PrintStream systemOut = mock(PrintStream.class);
    // when
    runConsistencyCheckToolWith(service, systemOut, args);
    // then
    ArgumentCaptor<Config> config = ArgumentCaptor.forClass(Config.class);
    verify(service).runFullConsistencyCheck(eq(storeDir), config.capture(), any(ProgressMonitorFactory.class), any(LogProvider.class), any(FileSystemAbstraction.class), anyBoolean(), any(CheckConsistencyConfig.class));
    assertTrue(config.getValue().get(ConsistencyCheckSettings.consistency_check_property_owners));
}
Also used : PrintStream(java.io.PrintStream) CheckConsistencyConfig(org.neo4j.consistency.checking.full.CheckConsistencyConfig) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) ProgressMonitorFactory(org.neo4j.helpers.progress.ProgressMonitorFactory) CheckConsistencyConfig(org.neo4j.consistency.checking.full.CheckConsistencyConfig) Config(org.neo4j.kernel.configuration.Config) FileWriter(java.io.FileWriter) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Properties(java.util.Properties) LogProvider(org.neo4j.logging.LogProvider) File(java.io.File) Test(org.junit.Test)

Example 72 with Config

use of org.neo4j.kernel.configuration.Config in project neo4j by neo4j.

the class ConsistencyCheckToolTest method appliesDefaultTuningConfigurationForConsistencyChecker.

@Test
public void appliesDefaultTuningConfigurationForConsistencyChecker() throws Exception {
    // given
    File storeDir = storeDirectory.directory();
    String[] args = { storeDir.getPath() };
    ConsistencyCheckService service = mock(ConsistencyCheckService.class);
    PrintStream systemOut = mock(PrintStream.class);
    // when
    runConsistencyCheckToolWith(service, systemOut, args);
    // then
    ArgumentCaptor<Config> config = ArgumentCaptor.forClass(Config.class);
    verify(service).runFullConsistencyCheck(eq(storeDir), config.capture(), any(ProgressMonitorFactory.class), any(LogProvider.class), any(FileSystemAbstraction.class), anyBoolean(), any(CheckConsistencyConfig.class));
    assertFalse(config.getValue().get(ConsistencyCheckSettings.consistency_check_property_owners));
}
Also used : PrintStream(java.io.PrintStream) LogProvider(org.neo4j.logging.LogProvider) CheckConsistencyConfig(org.neo4j.consistency.checking.full.CheckConsistencyConfig) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) ProgressMonitorFactory(org.neo4j.helpers.progress.ProgressMonitorFactory) CheckConsistencyConfig(org.neo4j.consistency.checking.full.CheckConsistencyConfig) Config(org.neo4j.kernel.configuration.Config) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) Test(org.junit.Test)

Example 73 with Config

use of org.neo4j.kernel.configuration.Config in project neo4j by neo4j.

the class IdGeneratorRebuildFailureEmulationTest method initialize.

@Before
public void initialize() {
    fs = new FileSystem();
    GraphDatabaseService graphdb = new Database(storeDir);
    createInitialData(graphdb);
    graphdb.shutdown();
    Map<String, String> params = new HashMap<>();
    params.put(GraphDatabaseSettings.rebuild_idgenerators_fast.name(), Settings.FALSE);
    Config config = Config.embeddedDefaults(params);
    factory = new StoreFactory(storeDir, config, new DefaultIdGeneratorFactory(fs), pageCacheRule.getPageCache(fs), fs, NullLogProvider.getInstance());
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) HashMap(java.util.HashMap) Config(org.neo4j.kernel.configuration.Config) ImpermanentGraphDatabase(org.neo4j.test.ImpermanentGraphDatabase) DefaultIdGeneratorFactory(org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory) Before(org.junit.Before)

Example 74 with Config

use of org.neo4j.kernel.configuration.Config 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 75 with Config

use of org.neo4j.kernel.configuration.Config 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)

Aggregations

Config (org.neo4j.kernel.configuration.Config)264 Test (org.junit.Test)184 File (java.io.File)54 PageCache (org.neo4j.io.pagecache.PageCache)35 InstanceId (org.neo4j.cluster.InstanceId)26 MultiPaxosContext (org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.context.MultiPaxosContext)25 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)25 LogProvider (org.neo4j.logging.LogProvider)20 Executor (java.util.concurrent.Executor)19 ClusterConfiguration (org.neo4j.cluster.protocol.cluster.ClusterConfiguration)19 Timeouts (org.neo4j.cluster.timeout.Timeouts)19 HashMap (java.util.HashMap)18 URI (java.net.URI)17 ObjectInputStreamFactory (org.neo4j.cluster.protocol.atomicbroadcast.ObjectInputStreamFactory)17 ObjectOutputStreamFactory (org.neo4j.cluster.protocol.atomicbroadcast.ObjectOutputStreamFactory)17 AcceptorInstanceStore (org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.AcceptorInstanceStore)17 IOException (java.io.IOException)16 ListenSocketAddress (org.neo4j.helpers.ListenSocketAddress)15 BoltConnector (org.neo4j.kernel.configuration.BoltConnector)15 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)15