Search in sources :

Example 1 with ClusterStateException

use of org.neo4j.causalclustering.core.state.ClusterStateException 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)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 ClusterStateDirectory (org.neo4j.causalclustering.core.state.ClusterStateDirectory)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