public void run() { // Random random = new Random(); for (int i = 0; i < times; i++) { try { MongoCollection collection = mongo.getDB("goojia").getCollection("goojia_common.ppc_map"); BSONDocument doc = new MongoDocument(); doc.put("city", "sh"); doc.put("category", 1); doc.put("relate_id", 123); doc.put("relate_id_2", 0); collection.find(doc).toList(); } catch (Exception e) { e.printStackTrace(); } } countDownLatch.countDown(); System.out.println("a"); }
public static void main(String[] args) throws Exception { Configuration config = new Configuration(); Mongo mongo = new MongoImpl(config, "127.0.0.1:27018", "127.0.0.1:27017", "127.0.0.1:27019"); MongoCollection collection = mongo.getDB("goojia").getCollection("goojia_common.ppc_map"); BSONDocument doc = new MongoDocument(); doc.put("city", "sh"); doc.put("category", 1); doc.put("relate_id", 123); doc.put("relate_id_2", 0); collection.save(doc); Thread.sleep(20000); doc = new MongoDocument(); doc.put("city", "bj"); doc.put("category", 12); doc.put("relate_id", 12344); doc.put("relate_id_2", 0); collection.save(doc); mongo.close(); }