Package com.mongodb

Examples of com.mongodb.DB.command()


            @Override
            public Object doRun() {
                Object res = null;
                try {
                    res = admin.command(cmd);
                } catch (MongoException.Network e) {
                    res = new BasicDBObject("msg", "Operation was likely successful, but connection was bounced");
                }
               
                try {
View Full Code Here


                    dbCapOpts.add("size", cap.value());
                if (cap.count() > 0)
                    dbCapOpts.add("max", cap.count());
                DB db = getDB();
                if (db.getCollectionNames().contains(collName)) {
                    DBObject dbResult = db.command(BasicDBObjectBuilder.start("collstats", collName).get());
                    if (dbResult.containsField("capped")) {
                        // TODO: check the cap options.
                        log.warning("DBCollection already exists is cap'd already; doing nothing. " + dbResult);
                    } else {
                        log.warning("DBCollection already exists with same name(" + collName
View Full Code Here

    public void shuffleChunks() throws IOException, InterruptedException, TimeoutException {
        assumeTrue(isSharded(getInputUri()));
        LOG.info("shuffling chunks across shards");

        DB adminDB = getClient(getInputUri()).getDB("admin");
        adminDB.command(new BasicDBObject("enablesharding", "mongo_hadoop"));

        getClient(getInputUri()).getDB("config").getCollection("settings").update(new BasicDBObject("_id", "balancer"),
                                                                     new BasicDBObject("$set", new BasicDBObject("stopped", true)),
                                                                     false,
                                                                     true);
View Full Code Here

        getClient(getInputUri()).getDB("config").getCollection("settings").update(new BasicDBObject("_id", "balancer"),
                                                                     new BasicDBObject("$set", new BasicDBObject("stopped", true)),
                                                                     false,
                                                                     true);
        adminDB.command(new BasicDBObject("shardCollection", "mongo_hadoop.yield_historical.in")
                            .append("key", new BasicDBObject("_id", 1)));

        DBCollection historicalIn = getClient(getInputUri()).getDB("mongo_hadoop").getCollection("yield_historical.in");

        for (int chunkpos : new int[]{2000, 3000, 1000, 500, 4000, 750, 250, 100, 3500, 2500, 2250, 1750}) {
View Full Code Here

        DBCollection historicalIn = getClient(getInputUri()).getDB("mongo_hadoop").getCollection("yield_historical.in");

        for (int chunkpos : new int[]{2000, 3000, 1000, 500, 4000, 750, 250, 100, 3500, 2500, 2250, 1750}) {
            Object middle = historicalIn.find().sort(new BasicDBObject("_id", 1)).skip(chunkpos).iterator().next().get("_id");
            adminDB.command(new BasicDBObject("split", "mongo_hadoop.yield_historical.in")
                                .append("middle", new BasicDBObject("_id", middle)));
        }

        DB configDB = getMongos().getDB("config");
        DBCollection shards = configDB.getCollection("shards");
View Full Code Here

    if (currentVersion == null) {
      try {
        MongoClient client;
        client = new MongoClient(host, port);
        DB db = client.getDB("test");
        CommandResult result = db.command(new BasicDBObjectBuilder().add("buildInfo", 1).get());
        this.currentVersion = Version.parse(result.get("version").toString());
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
View Full Code Here

        DB db = new MongoClient().getDB( "driver_test_framework" );
        DBObject foo = new BasicDBObject();
        foo.put( "create", "capped1" );
        foo.put( "capped", true );
        foo.put( "size", 500 );
        DBObject dbobj = db.command( foo );
        DBCollection c = db.getCollection( "capped1" );

        DBObject obj1 = new BasicDBObject();
        obj1.put( "x", 1 );
        c.save( obj1 );
View Full Code Here

        obj2.put( "x", 2 );
        c.save( obj2 );

        foo.put( "create", "capped2" );
        foo.put( "size", 1000 );
        db.command( foo );
        String s = "";
        c = db.getCollection( "capped2" );
        for( int i=1; i<= 100; i++ ) {
            DBObject obj = new BasicDBObject();
            obj.put( "dashes", s );
View Full Code Here

        }

        db.getCollection( "dbs_1" ).drop();
        o = new BasicDBObject();
        o.put( "create", "dbs_3" );
        db.command( o );

        set = db.getCollectionNames();
        strs = set.toArray( new String[0] );
        Arrays.sort( strs );
        for( String s : strs ) {
View Full Code Here

  private static BuildInfo initBuildInfo(Mongo mongo) {
    DB db = mongo.getDB("admin");
    if (db == null) {
      return null;
    }
    CommandResult cr = db.command("buildInfo");
    String version = (String)cr.get("version");
    if (version == null) {
      return null;
    }
    String[] vss = version.split("\\.");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.