use of org.neo4j.commandline.admin.CommandFailed in project neo4j by neo4j.
the class UnbindFromClusterCommandTest method shouldFailToUnbindLiveDatabase.
@Test
public void shouldFailToUnbindLiveDatabase() throws Exception {
// given
createClusterStateDir(fs);
UnbindFromClusterCommand command = new UnbindFromClusterCommand(homeDir, confDir, outsideWorld);
FileLock fileLock = createLockedFakeDbDir(homeDir);
try {
// when
command.execute(databaseNameParameter("graph.db"));
fail();
} catch (CommandFailed e) {
// then
assertThat(e.getMessage(), containsString("Database is currently locked. Please shutdown Neo4j."));
} finally {
fileLock.release();
}
}
use of org.neo4j.commandline.admin.CommandFailed in project neo4j by neo4j.
the class VersionCommand method execute.
@Override
public void execute(String[] args) throws IncorrectUsage, CommandFailed {
final Path storeDir = arguments.parseMandatoryPath("store", args);
Validators.CONTAINS_EXISTING_DATABASE.validate(storeDir.toFile());
try (DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
PageCache pageCache = StandalonePageCacheFactory.createPageCache(fileSystem)) {
final String storeVersion = new StoreVersionCheck(pageCache).getVersion(storeDir.resolve(MetaDataStore.DEFAULT_NAME).toFile()).orElseThrow(() -> new CommandFailed(String.format("Could not find version metadata in store '%s'", storeDir)));
final String fmt = "%-25s%s";
out.accept(String.format(fmt, "Store format version:", storeVersion));
RecordFormats format = RecordFormatSelector.selectForVersion(storeVersion);
out.accept(String.format(fmt, "Introduced in version:", format.introductionVersion()));
findSuccessor(format).map(next -> String.format(fmt, "Superseded in version:", next.introductionVersion())).ifPresent(out);
out.accept(String.format(fmt, "Current version:", Version.getNeo4jVersion()));
} catch (IOException e) {
throw new CommandFailed(e.getMessage(), e);
}
}
use of org.neo4j.commandline.admin.CommandFailed in project neo4j by neo4j.
the class DumpCommandTest method shouldGiveAClearMessageIfTheArchivesParentDoesntExist.
@Test
public void shouldGiveAClearMessageIfTheArchivesParentDoesntExist() throws Exception {
doThrow(new NoSuchFileException(archive.getParent().toString())).when(dumper).dump(any(), any(), any());
try {
execute("foo.db");
fail("expected exception");
} catch (CommandFailed e) {
assertThat(e.getMessage(), equalTo("unable to dump database: NoSuchFileException: " + archive.getParent()));
}
}
use of org.neo4j.commandline.admin.CommandFailed in project neo4j by neo4j.
the class DumpCommandTest method shouldRespectTheStoreLock.
@Test
public void shouldRespectTheStoreLock() throws Exception {
Path databaseDirectory = homeDir.resolve("data/databases/foo.db");
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
StoreLocker storeLocker = new StoreLocker(fileSystem)) {
storeLocker.checkLock(databaseDirectory.toFile());
execute("foo.db");
fail("expected exception");
} catch (CommandFailed e) {
assertThat(e.getMessage(), equalTo("the database is in use -- stop Neo4j and try again"));
}
}
use of org.neo4j.commandline.admin.CommandFailed in project neo4j by neo4j.
the class LoadCommandTest method shouldRespectTheStoreLock.
@Test
public void shouldRespectTheStoreLock() throws IOException, IncorrectUsage {
Path databaseDirectory = homeDir.resolve("data/databases/foo.db");
Files.createDirectories(databaseDirectory);
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
StoreLocker locker = new StoreLocker(fileSystem)) {
locker.checkLock(databaseDirectory.toFile());
execute("foo.db", "--force");
fail("expected exception");
} catch (CommandFailed e) {
assertThat(e.getMessage(), equalTo("the database is in use -- stop Neo4j and try again"));
}
}
Aggregations