Search in sources :

Example 1 with ClusterStateDirectory

use of org.neo4j.causalclustering.core.state.ClusterStateDirectory in project neo4j by neo4j.

the class UnbindFromClusterCommandTest method createClusterStateDir.

private File createClusterStateDir(FileSystemAbstraction fs) throws ClusterStateException {
    File dataDir = new File(homeDir.toFile(), "data");
    ClusterStateDirectory clusterStateDirectory = new ClusterStateDirectory(dataDir, false);
    clusterStateDirectory.initialize(fs);
    return clusterStateDirectory.get();
}
Also used : ClusterStateDirectory(org.neo4j.causalclustering.core.state.ClusterStateDirectory) File(java.io.File)

Example 2 with ClusterStateDirectory

use of org.neo4j.causalclustering.core.state.ClusterStateDirectory in project neo4j by neo4j.

the class UnbindFromClusterCommand method execute.

@Override
public void execute(String[] args) throws IncorrectUsage, CommandFailed {
    try {
        Config config = loadNeo4jConfig(homeDir, configDir, arguments.parse("database", args));
        File dataDirectory = config.get(DatabaseManagementSystemSettings.data_directory);
        Path pathToSpecificDatabase = config.get(DatabaseManagementSystemSettings.database_path).toPath();
        Validators.CONTAINS_EXISTING_DATABASE.validate(pathToSpecificDatabase.toFile());
        confirmTargetDirectoryIsWritable(pathToSpecificDatabase);
        ClusterStateDirectory clusterStateDirectory = new ClusterStateDirectory(dataDirectory);
        clusterStateDirectory.initialize(outsideWorld.fileSystem());
        deleteClusterStateIn(clusterStateDirectory.get().toPath());
    } catch (StoreLockException e) {
        throw new CommandFailed("Database is currently locked. Please shutdown Neo4j.", e);
    } catch (IllegalArgumentException e) {
        throw new IncorrectUsage(e.getMessage());
    } catch (UnbindFailureException | CannotWriteException | IOException | ClusterStateException e) {
        throw new CommandFailed(e.getMessage(), e);
    }
}
Also used : Path(java.nio.file.Path) ClusterStateDirectory(org.neo4j.causalclustering.core.state.ClusterStateDirectory) Config(org.neo4j.kernel.configuration.Config) StoreLockException(org.neo4j.kernel.StoreLockException) IOException(java.io.IOException) IncorrectUsage(org.neo4j.commandline.admin.IncorrectUsage) CommandFailed(org.neo4j.commandline.admin.CommandFailed) ClusterStateException(org.neo4j.causalclustering.core.state.ClusterStateException) File(java.io.File)

Aggregations

File (java.io.File)2 ClusterStateDirectory (org.neo4j.causalclustering.core.state.ClusterStateDirectory)2 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ClusterStateException (org.neo4j.causalclustering.core.state.ClusterStateException)1 CommandFailed (org.neo4j.commandline.admin.CommandFailed)1 IncorrectUsage (org.neo4j.commandline.admin.IncorrectUsage)1 StoreLockException (org.neo4j.kernel.StoreLockException)1 Config (org.neo4j.kernel.configuration.Config)1