Search in sources :

Example 1 with Args

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);
    }
}
Also used : LogProvider(org.neo4j.logging.LogProvider) FormattedLogProvider(org.neo4j.logging.FormattedLogProvider) Args(org.neo4j.helpers.Args) CheckConsistencyConfig(org.neo4j.consistency.checking.full.CheckConsistencyConfig) Config(org.neo4j.kernel.configuration.Config) CheckConsistencyConfig(org.neo4j.consistency.checking.full.CheckConsistencyConfig) ConsistencyCheckIncompleteException(org.neo4j.consistency.checking.full.ConsistencyCheckIncompleteException) File(java.io.File)

Example 2 with Args

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);
    }
}
Also used : Args(org.neo4j.helpers.Args)

Example 3 with Args

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;
}
Also used : Args(org.neo4j.helpers.Args) RmiLocation(org.neo4j.shell.impl.RmiLocation) ArrayList(java.util.ArrayList) Exceptions.launderedException(org.neo4j.helpers.Exceptions.launderedException) RemoteException(java.rmi.RemoteException) ExecutorService(java.util.concurrent.ExecutorService) ProcessStreamHandler(org.neo4j.test.ProcessStreamHandler) RemoteException(java.rmi.RemoteException)

Example 4 with Args

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);
}
Also used : Args(org.neo4j.helpers.Args) File(java.io.File)

Example 5 with Args

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);
    }
}
Also used : Args(org.neo4j.helpers.Args) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) File(java.io.File) FormattedLogProvider(org.neo4j.logging.FormattedLogProvider)

Aggregations

Args (org.neo4j.helpers.Args)16 File (java.io.File)12 DefaultFileSystemAbstraction (org.neo4j.io.fs.DefaultFileSystemAbstraction)7 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)6 PrintStream (java.io.PrintStream)3 Config (org.neo4j.kernel.configuration.Config)3 FormattedLogProvider (org.neo4j.logging.FormattedLogProvider)3 IOException (java.io.IOException)2 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)2 LogProvider (org.neo4j.logging.LogProvider)2 Input (org.neo4j.unsafe.impl.batchimport.input.Input)2 IdType (org.neo4j.unsafe.impl.batchimport.input.csv.IdType)2 BufferedOutputStream (java.io.BufferedOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Charset (java.nio.charset.Charset)1 Charset.defaultCharset (java.nio.charset.Charset.defaultCharset)1 RemoteException (java.rmi.RemoteException)1