use of org.neo4j.tools.console.input.ArgsCommand in project neo4j by neo4j.
the class DatabaseRebuildTool method console.
private ConsoleInput console(final File fromPath, final GraphDatabaseBuilder dbBuilder, InputStream in, Listener<PrintStream> prompt, LifeSupport life) throws Exception {
// We must have this indirection here since in order to perform CC (one of the commands) we must shut down
// the database and let CC instantiate its own to run on. After that completes the db
// should be restored. The commands has references to providers of things to accommodate for this.
final AtomicReference<Store> store = new AtomicReference<>(new Store(dbBuilder));
final Supplier<StoreAccess> storeAccess = () -> store.get().access;
final Supplier<GraphDatabaseAPI> dbAccess = () -> store.get().db;
ConsoleInput consoleInput = life.add(new ConsoleInput(in, out, prompt));
consoleInput.add("apply", new ApplyTransactionsCommand(fromPath, dbAccess));
consoleInput.add(DumpRecordsCommand.NAME, new DumpRecordsCommand(storeAccess));
consoleInput.add("cc", new ArgsCommand() {
@Override
public void run(Args action, PrintStream out) throws Exception {
File storeDir = store.get().storeDir;
store.get().shutdown();
try {
Result result = new ConsistencyCheckService().runFullConsistencyCheck(storeDir, Config.defaults(), ProgressMonitorFactory.textual(out), FormattedLogProvider.toOutputStream(System.out), false);
out.println(result.isSuccessful() ? "consistent" : "INCONSISTENT");
} finally {
store.set(new Store(dbBuilder));
}
}
@Override
public String toString() {
return "Runs consistency check on the database for data that has been applied up to this point";
}
});
life.add(new LifecycleAdapter() {
@Override
public void shutdown() {
store.get().shutdown();
}
});
return consoleInput;
}
Aggregations