Exemplo n.º 1
0
    Status addMongoOplogOptions(moe::OptionSection* options) {
        Status ret = addGeneralToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addRemoteServerToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addLocalServerToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addSpecifyDBCollectionToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        options->addOptionChaining("seconds", "seconds,s", moe::Int,
                "seconds to go back default:86400");

        options->addOptionChaining("from", "from", moe::String, "host to pull from");

        options->addOptionChaining("oplogns", "oplogns", moe::String, "ns to pull from")
                                  .setDefault(moe::Value(std::string("local.oplog.rs")));


        return Status::OK();
    }
Exemplo n.º 2
0
    Status addMongoFilesOptions(moe::OptionSection* options) {
        Status ret = addGeneralToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addRemoteServerToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addLocalServerToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addSpecifyDBCollectionToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = options->addOption(OD("local", "local,l", moe::String,
                    "local filename for put|get (default is to use the same name as "
                    "'gridfs filename')", true));
        if(!ret.isOK()) {
            return ret;
        }
        ret = options->addOption(OD("type", "type,t", moe::String,
                    "MIME type for put (default is to omit)", true));
        if(!ret.isOK()) {
            return ret;
        }
        ret = options->addOption(OD("replace", "replace,r", moe::Switch,
                    "Remove other files with same name after PUT", true));
        if(!ret.isOK()) {
            return ret;
        }

        ret = options->addPositionalOption(POD( "command", moe::String, 1 ));
        if(!ret.isOK()) {
            return ret;
        }
        ret = options->addPositionalOption(POD( "file", moe::String, 2 ));
        if(!ret.isOK()) {
            return ret;
        }

        return Status::OK();
    }
    Status addMongoFilesOptions(moe::OptionSection* options) {
        Status ret = addGeneralToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addRemoteServerToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addLocalServerToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addSpecifyDBCollectionToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        options->addOptionChaining("local", "local,l", moe::String,
                "local filename for put|get (default is to use the same name as "
                "'gridfs filename')");

        options->addOptionChaining("type", "type,t", moe::String,
                "MIME type for put (default is to omit)");

        options->addOptionChaining("replace", "replace,r", moe::Switch,
                "Remove other files with same name after PUT");

        options->addOptionChaining("command", "command", moe::String,
                "gridfs command to run")
                                  .hidden()
                                  .setSources(moe::SourceCommandLine)
                                  .positional(1, 1);

        options->addOptionChaining("file", "file", moe::String,
                "'gridfs filename' with a special meaning for various commands")
                                  .hidden()
                                  .setSources(moe::SourceCommandLine)
                                  .positional(2, 2);


        return Status::OK();
    }
Exemplo n.º 4
0
    Status addMongoDumpOptions(moe::OptionSection* options) {
        Status ret = addGeneralToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addRemoteServerToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addLocalServerToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addSpecifyDBCollectionToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        options->addOptionChaining("out", "out,o", moe::String,
                "output directory or \"-\" for stdout")
                                  .setDefault(moe::Value(std::string("dump")));

        options->addOptionChaining("query", "query,q", moe::String, "json query");

        options->addOptionChaining("oplog", "oplog", moe::Switch,
                "Use oplog for point-in-time snapshotting");

        options->addOptionChaining("repair", "repair", moe::Switch,
                "try to recover a crashed database");

        options->addOptionChaining("forceTableScan", "forceTableScan", moe::Switch,
                "force a table scan (do not use $snapshot)");


        return Status::OK();
    }
Exemplo n.º 5
0
    Status addMongoImportOptions(moe::OptionSection* options) {
        Status ret = addGeneralToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addRemoteServerToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addLocalServerToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addSpecifyDBCollectionToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addFieldOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        options->addOptionChaining("ignoreBlanks", "ignoreBlanks", moe::Switch,
                "if given, empty fields in csv and tsv will be ignored");

        options->addOptionChaining("type", "type", moe::String,
                "type of file to import.  default: json (json,csv,tsv)");

        options->addOptionChaining("file", "file", moe::String,
                "file to import from; if not specified stdin is used");

        options->addOptionChaining("drop", "drop", moe::Switch, "drop collection first ");

        options->addOptionChaining("headerline", "headerline", moe::Switch,
                "first line in input file is a header (CSV and TSV only)");

        options->addOptionChaining("upsert", "upsert", moe::Switch,
                "insert or update objects that already exist");

        options->addOptionChaining("upsertFields", "upsertFields", moe::String,
                "comma-separated fields for the query part of the upsert. "
                "You should make sure this is indexed");

        options->addOptionChaining("stopOnError", "stopOnError", moe::Switch,
                "stop importing at first error rather than continuing");

        options->addOptionChaining("jsonArray", "jsonArray", moe::Switch,
                "load a json array, not one item per line. Currently limited to 16MB.");


        options->addOptionChaining("noimport", "noimport", moe::Switch,
                "don't actually import. useful for benchmarking parser")
                                  .hidden();


        ret = options->addPositionalOption(POD( "file", moe::String, 1 ));
        if(!ret.isOK()) {
            return ret;
        }

        return Status::OK();
    }
Exemplo n.º 6
0
    Status addMongoRestoreOptions(moe::OptionSection* options) {
        Status ret = addGeneralToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addRemoteServerToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addLocalServerToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addSpecifyDBCollectionToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        ret = addBSONToolOptions(options);
        if (!ret.isOK()) {
            return ret;
        }

        options->addOptionChaining("drop", "drop", moe::Switch,
                "drop each collection before import");

        options->addOptionChaining("oplogReplay", "oplogReplay", moe::Switch,
                "replay oplog for point-in-time restore");

        options->addOptionChaining("oplogLimit", "oplogLimit", moe::String,
                "include oplog entries before the provided Timestamp "
                "(seconds[:ordinal]) during the oplog replay; "
                "the ordinal value is optional");

        options->addOptionChaining("keepIndexVersion", "keepIndexVersion", moe::Switch,
                "don't upgrade indexes to newest version");

        options->addOptionChaining("noOptionsRestore", "noOptionsRestore", moe::Switch,
                "don't restore collection options");

        options->addOptionChaining("noIndexRestore", "noIndexRestore", moe::Switch,
                "don't restore indexes");

        options->addOptionChaining("w", "w", moe::Int, "minimum number of replicas per write")
                                  .setDefault(moe::Value(0));

        options->addOptionChaining("dir", "dir", moe::String, "directory to restore from")
                                  .hidden()
                                  .setDefault(moe::Value(std::string("dump")));


        // left in for backwards compatibility
        options->addOptionChaining("indexesLast", "indexesLast", moe::Switch,
                "wait to add indexes (now default)")
                                  .hidden();


        ret = options->addPositionalOption(POD("dir", moe::String, 1));
        if(!ret.isOK()) {
            return ret;
        }

        return Status::OK();
    }