/** * Drops the collection that holds the results. Does nothing if the map-reduce returned the results inline. */ public void drop() { if (collection != null) { collection.drop(); } }
@Override public boolean removeQueue(String taskTrackerNodeGroup) { String tableName = JobQueueUtils.getExecutableQueueName(taskTrackerNodeGroup); DBCollection dbCollection = template.getCollection(tableName); dbCollection.drop(); LOGGER.info("drop queue " + tableName); return true; }
@Override public boolean removeQueue(String jobClientNodeGroup) { String tableName = JobQueueUtils.getFeedbackQueueName(jobClientNodeGroup); DBCollection dbCollection = template.getCollection(tableName); dbCollection.drop(); LOGGER.info("drop queue " + tableName); return true; }
@Override public boolean removeQueue(String taskTrackerNodeGroup) { String tableName = JobQueueUtils.getExecutableQueueName(taskTrackerNodeGroup); DBCollection dbCollection = template.getCollection(tableName); dbCollection.drop(); LOGGER.info("drop queue " + tableName); return true; }
@Override public boolean removeQueue(String jobClientNodeGroup) { String tableName = JobQueueUtils.getFeedbackQueueName(jobClientNodeGroup); DBCollection dbCollection = template.getCollection(tableName); dbCollection.drop(); LOGGER.info("drop queue " + tableName); return true; }
private void turnOffProfilingAndDropProfileCollection() { getDb().command(new BasicDBObject("profile", 0)); DBCollection profileCollection = getDb().getCollection("system.profile"); profileCollection.drop(); }
@Test public void testTextAnnotation() { Class<SingleFieldTextIndex> clazz = SingleFieldTextIndex.class; getMorphia().map(clazz); getDs().getCollection(clazz).drop(); getDs().ensureIndexes(); List<DBObject> indexInfo = getDs().getCollection(clazz).getIndexInfo(); Assert.assertEquals(indexInfo.toString(), 2, indexInfo.size()); boolean found = false; for (DBObject dbObject : indexInfo) { if (dbObject.get("name").equals("single_annotation")) { found = true; Assert.assertEquals(dbObject.toString(), "english", dbObject.get("default_language")); Assert.assertEquals(dbObject.toString(), "nativeTongue", dbObject.get("language_override")); Assert.assertEquals(dbObject.toString(), 10, ((DBObject) dbObject.get("weights")).get("nickName")); } } Assert.assertTrue(indexInfo.toString(), found); }
@Test(expected = MongoCommandException.class) public void shouldNotAllowMultipleTextIndexes() { Class<MultipleTextIndexes> clazz = MultipleTextIndexes.class; getMorphia().map(clazz); getDs().getCollection(clazz).drop(); getDs().ensureIndexes(); }
@Test public void testSingleAnnotation() { getMorphia().map(CompoundTextIndex.class); getDs().getCollection(CompoundTextIndex.class).drop(); getDs().ensureIndexes(); List<DBObject> indexInfo = getDs().getCollection(CompoundTextIndex.class).getIndexInfo(); Assert.assertEquals(2, indexInfo.size()); boolean found = false; for (DBObject dbObject : indexInfo) { if (dbObject.get("name").equals("indexing_test")) { found = true; Assert.assertEquals(dbObject.toString(), "russian", dbObject.get("default_language")); Assert.assertEquals(dbObject.toString(), "nativeTongue", dbObject.get("language_override")); Assert.assertEquals(dbObject.toString(), 1, ((DBObject) dbObject.get("weights")).get("name")); Assert.assertEquals(dbObject.toString(), 10, ((DBObject) dbObject.get("weights")).get("nick")); Assert.assertEquals(dbObject.toString(), 1, ((DBObject) dbObject.get("key")).get("age")); } } Assert.assertTrue(found); }
@Test public void testReference() { getMorphia().map(CompoundIdEntity.class, CompoundId.class); getDs().getCollection(CompoundIdEntity.class).drop(); final CompoundIdEntity sibling = new CompoundIdEntity(); sibling.id = new CompoundId("sibling ID"); getDs().save(sibling); final CompoundIdEntity entity = new CompoundIdEntity(); entity.id = new CompoundId("entity ID"); entity.e = "some value"; entity.sibling = sibling; getDs().save(entity); final CompoundIdEntity loaded = getDs().get(entity); Assert.assertEquals(entity, loaded); }
@Test public void testDeleteWithCollation() { checkMinServerVersion(3.4); getDs().getCollection(FacebookUser.class).drop(); getDs().save(asList(new FacebookUser(1, "John Doe"), new FacebookUser(2, "john doe"))); Query<FacebookUser> query = getDs().find(FacebookUser.class) .field("username").equal("john doe"); assertEquals(1, getDs().delete(query).getN()); assertEquals(1, getDs().delete(query, new DeleteOptions() .collation(Collation.builder() .locale("en") .collationStrength(CollationStrength.SECONDARY) .build())) .getN()); }
@Test public void testFindAndDeleteWithCollation() { checkMinServerVersion(3.4); getDs().getCollection(FacebookUser.class).drop(); getDs().save(asList(new FacebookUser(1, "John Doe"), new FacebookUser(2, "john doe"))); Query<FacebookUser> query = getDs().find(FacebookUser.class) .field("username").equal("john doe"); assertNotNull(getDs().findAndDelete(query)); assertNull(getDs().findAndDelete(query)); FindAndModifyOptions options = new FindAndModifyOptions() .collation(Collation.builder() .locale("en") .collationStrength(CollationStrength.SECONDARY) .build()); assertNotNull(getDs().findAndDelete(query, options)); assertTrue("Options should not be modified by the datastore", options.isReturnNew()); assertFalse("Options should not be modified by the datastore", options.isRemove()); }
assertEquals(1, hotelDAO.count()); hotelDAO.getCollection().drop(); assertEquals(0, hotelDAO.count());
assertEquals(1, hotelDAO.count()); hotelDAO.getCollection().drop(); assertEquals(0, hotelDAO.count());
@Test public void testUpdateWithCollation() { checkMinServerVersion(3.4); getDs().getCollection(FacebookUser.class).drop(); getDs().save(asList(new FacebookUser(1, "John Doe"), new FacebookUser(2, "john doe")));
@Test @SuppressWarnings("deprecation") public void testFindAndModifyOld() { getDs().getCollection(FacebookUser.class).drop(); getDs().save(asList(new FacebookUser(1, "John Doe"), new FacebookUser(2, "john doe")));
@Test public void testFindAndModify() { getDs().getCollection(FacebookUser.class).drop(); getDs().save(asList(new FacebookUser(1, "John Doe"), new FacebookUser(2, "john doe")));
@Test public void testFindAndModifyWithOptions() { checkMinServerVersion(3.4); getDs().getCollection(FacebookUser.class).drop(); getDs().save(asList(new FacebookUser(1, "John Doe"), new FacebookUser(2, "john doe")));