use of org.neo4j.helpers.Args 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);
}
}
use of org.neo4j.helpers.Args in project neo4j by neo4j.
the class StartClient method start.
// visible for testing
void start(String[] arguments, CtrlCHandler signalHandler) {
Args args = Args.withFlags(ARG_READONLY).parse(arguments);
if (args.has("?") || args.has("h") || args.has("help") || args.has("usage")) {
printUsage(out);
return;
}
String path = args.get(ARG_PATH, null);
String host = args.get(ARG_HOST, null);
String port = args.get(ARG_PORT, null);
String name = args.get(ARG_NAME, null);
String pid = args.get(ARG_PID, null);
boolean version = args.getBoolean(ARG_VERSION, false, true);
if (version) {
String edition = StringUtils.capitalize(factory.getEdition().toLowerCase());
out.printf("Neo4j %s, version %s", edition, Version.getNeo4jVersion());
} else if ((path != null && (port != null || name != null || host != null || pid != null)) || (pid != null && host != null)) {
err.println("You have supplied both " + ARG_PATH + " as well as " + ARG_HOST + "/" + ARG_PORT + "/" + ARG_NAME + ". " + "You should either supply only " + ARG_PATH + " or " + ARG_HOST + "/" + ARG_PORT + "/" + ARG_NAME + " so that either a local or " + "remote shell client can be started");
} else // Local
if (path != null) {
try {
checkNeo4jDependency();
} catch (ShellException e) {
throw new ShellExecutionFailureException(e, args);
}
startLocal(args, signalHandler);
} else // Remote
{
String readonly = args.get(ARG_READONLY, null);
if (readonly != null) {
err.println("Warning: -" + ARG_READONLY + " is ignored unless you connect with -" + ARG_PATH + "!");
}
// Start server on the supplied process
if (pid != null) {
startServer(pid, args);
}
startRemote(args, signalHandler);
}
}
use of org.neo4j.helpers.Args in project neo4j by neo4j.
the class LegacyDatabaseImpl method start.
public static Future<LegacyDatabase> start(String classpath, File storeDir, Map<String, String> config) throws Exception {
List<String> args = new ArrayList<String>();
args.add(storeDir.getAbsolutePath());
int rmiPort = 7000 + parseInt(config.get("ha.server_id"));
args.add("" + rmiPort);
args.addAll(asList(new Args(config).asArgs()));
final Process process = execJava(appendNecessaryTestClasses(classpath), LegacyDatabaseImpl.class.getName(), args.toArray(new String[0]));
new ProcessStreamHandler(process, false).launch();
final RmiLocation rmiLocation = rmiLocation(rmiPort);
ExecutorService executor = newSingleThreadExecutor();
Future<LegacyDatabase> future = executor.submit(new Callable<LegacyDatabase>() {
@Override
public LegacyDatabase call() throws Exception {
long endTime = currentTimeMillis() + SECONDS.toMillis(10000);
while (currentTimeMillis() < endTime) {
try {
return (LegacyDatabase) rmiLocation.getBoundObject();
} catch (RemoteException e) {
// OK
sleep(100);
}
}
process.destroy();
throw new IllegalStateException("Couldn't get remote to legacy database");
}
});
executor.shutdown();
return future;
}
use of org.neo4j.helpers.Args in project neo4j by neo4j.
the class DumpStoreChain method main.
public static void main(String... args) throws Exception {
Args arguments = Args.withFlags(REVERSE, RELS, PROPS).parse(args);
List<String> orphans = arguments.orphans();
if (orphans.size() != 1) {
throw invalidUsage("no store file given");
}
File storeFile = new File(orphans.get(0));
DumpStoreChain tool;
if (storeFile.isDirectory()) {
verifyFilesExists(new File(storeFile, NODESTORE), new File(storeFile, RELSTORE), new File(storeFile, PROPSTORE));
tool = chainForNode(arguments);
} else {
verifyFilesExists(storeFile);
if (RELSTORE.equals(storeFile.getName())) {
tool = relationshipChain(arguments);
} else if (PROPSTORE.equals(storeFile.getName())) {
tool = propertyChain(arguments);
} else {
throw invalidUsage("not a chain store: " + storeFile.getName());
}
}
tool.dump(storeFile);
}
use of org.neo4j.helpers.Args in project neo4j by neo4j.
the class StoreMigration method main.
public static void main(String[] args) throws IOException {
Args arguments = Args.withFlags(HELP_FLAG).parse(args);
if (arguments.getBoolean(HELP_FLAG, false) || args.length == 0) {
printUsageAndExit();
}
File storeDir = parseDir(arguments);
FormattedLogProvider userLogProvider = FormattedLogProvider.toOutputStream(System.out);
try (FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction()) {
new StoreMigration().run(fileSystem, storeDir, getMigrationConfig(), userLogProvider);
}
}
Aggregations