logger.info("MongoDBRiver is beginning initial import of " + collection.getFullName()); boolean inProgress = true; String lastId = null; lastId = addInsertToStream(null, applyFieldFilter(object), collection.getName()); } else { logger.debug("Last entry for initial import of {} - add timestamp: {}", collection.getFullName(), timestamp); lastId = addInsertToStream(timestamp, applyFieldFilter(object), collection.getName()); logger.info("Number of documents indexed in initial import of {}: {}", collection.getFullName(), count); } else { lastId = addInsertToStream(null, file); } else { logger.debug("Last entry for initial import of {} - add timestamp: {}", collection.getFullName(), timestamp); lastId = addInsertToStream(timestamp, file);
@Test @SuppressWarnings("deprecation") public void testCommentsShowUpInLogsOld() { getDs().save(asList(new Pic("pic1"), new Pic("pic2"), new Pic("pic3"), new Pic("pic4"))); getDb().command(new BasicDBObject("profile", 2)); String expectedComment = "test comment"; toList(getDs().find(Pic.class).comment(expectedComment).find()); DBCollection profileCollection = getDb().getCollection("system.profile"); assertNotEquals(0, profileCollection.count()); DBObject profileRecord = profileCollection.findOne(new BasicDBObject("op", "query") .append("ns", getDs().getCollection(Pic.class).getFullName())); assertEquals(profileRecord.toString(), expectedComment, getCommentFromProfileRecord(profileRecord)); turnOffProfilingAndDropProfileCollection(); }
@Test public void testCommentsShowUpInLogs() { getDs().save(asList(new Pic("pic1"), new Pic("pic2"), new Pic("pic3"), new Pic("pic4"))); getDb().command(new BasicDBObject("profile", 2)); String expectedComment = "test comment"; toList(getDs().find(Pic.class) .find(new FindOptions() .modifier("$comment", expectedComment))); DBCollection profileCollection = getDb().getCollection("system.profile"); assertNotEquals(0, profileCollection.count()); DBObject profileRecord = profileCollection.findOne(new BasicDBObject("op", "query") .append("ns", getDs().getCollection(Pic.class).getFullName())); assertEquals(profileRecord.toString(), expectedComment, getCommentFromProfileRecord(profileRecord)); turnOffProfilingAndDropProfileCollection(); }
private void createUniqueIndexGFS(DBCollection coll, String id) { try { coll.createIndex(new BasicDBObject("metadata." + id, 1), new BasicDBObject("unique", true)); } catch (MongoException ex) { throw new KunderaException("Error in creating unique indexes in " + coll.getFullName() + " collection on " + id + " field"); } }
/** * Creates the unique index gfs. * * @param coll * the coll * @param id * the id */ private void createUniqueIndexGFS(DBCollection coll, String id) { try { coll.createIndex(new BasicDBObject("metadata." + id, 1), new BasicDBObject("unique", true)); } catch (MongoException ex) { throw new KunderaException("Error in creating unique indexes in " + coll.getFullName() + " collection on " + id + " field"); } }
/** * On collections flush. * * @param collections * collection containing records to be inserted in mongo db. */ private void onFlushCollection(Map<String, List<DBObject>> collections) { for (String tableName : collections.keySet()) { DBCollection dbCollection = mongoDb.getCollection(tableName); KunderaCoreUtils.printQuery("Persist collection:" + tableName, showQuery); try { dbCollection.insert(collections.get(tableName).toArray(new DBObject[0]), getWriteConcern(), encoder); } catch (MongoException ex) { throw new KunderaException("document is not inserted in " + dbCollection.getFullName() + " collection. Caused By:", ex); } } }
Level.WARNING, "More than one indexed geometry field found for type {0}, selecting {1} (first one encountered with index search of collection {2})", new Object[] {name, geometryField, collection.getFullName()}); Level.INFO, "building type {0}: mapping geometry field {1} from collection {2}", new Object[] {name, geometryField, collection.getFullName()}); Level.INFO, "building type \"{0}\": mapping field \"{1}\" with binding {2} from collection {3}", new Object[] {name, field, binding.getName(), collection.getFullName()}); Level.INFO, "building type \"{0}\": mapping indexed field \"{1}\" with default binding, {2}, from collection {3}", new Object[] {name, field, String.class.getName(), collection.getFullName()});
geometryName, geometryMapping, collection.getFullName() }); Level.INFO, "Ignoring collection \"{0}\", unable to find key with spatial index", new Object[] {collection.getFullName()});
/** * Returns the full name of this collection, with the database name as a prefix. * * @return the name of this collection */ public String getFullName() { return dbCollection.getFullName(); }
/** * Returns the full name of this collection, with the database name as a prefix. * * @return the name of this collection */ public String getFullName() { return dbCollection.getFullName(); }
/** * Returns the full name of this collection, with the database name as a * prefix. * * @return the name of this collection */ public String getFullName() { return dbCollection.getFullName(); }
public MongoSequenceGenerator(DBCollection coll) { this.coll = coll; if (!initializedCollections.contains(coll.getFullName())) { // Here, we also make sure we have the indexes setup properly initIndex(); initializedCollections.add(coll.getFullName()); LOGGER.info("Initialized sequances collection {}", coll.getFullName()); } }
public void init(boolean forceCollectionInit) { // Make sure we have a unique index on resourceid // ensureIndex was deprecated, changed to an alias of createIndex, and removed in a more recent version if (forceCollectionInit || !initializedCollections.contains(coll.getFullName())) { BasicDBObject keys = new BasicDBObject(RESOURCEID, 1); BasicDBObject options = new BasicDBObject("unique", 1); this.coll.createIndex(keys, options); initializedCollections.add(coll.getFullName()); LOGGER.info("Initialized locking collection {}", coll.getFullName()); } }
public void showProgressCollectionStart( @Nonnull final DBCollection collection, final int count) { assert collection != null; LOG.debug(""); LOG.debug("{}:", collection.getFullName()); LOG.info(" | 0% -- processed 0 of {} records ({} errors and {} warnings found so far) - {}", count, errors.size(), warnings.size(), errors.isEmpty() ? "OK" : "not OK"); }
@Autowired MongoTemplate mongoTemplate; public String mongoTest() { DBCollection dc = mongoTemplate.getCollection("yourCollection"); logger.debug("--get collection name=" + dc.getFullName()); }
private static void safeInsert(DBCollection c, DBObject o) { if (c == null) { throw new RuntimeException("collection must not be null"); } if (o == null) { throw new RuntimeException("object must not be null"); } try { c.insert(o); } catch (NullPointerException e) { throw new RuntimeException("unable to connect to MongoDB " + c.getFullName(), e); } }
private void createUniqueIndexGFS(DBCollection coll, String id) { try { coll.createIndex(new BasicDBObject("metadata." + id, 1), new BasicDBObject("unique", true)); } catch (MongoException ex) { throw new KunderaException("Error in creating unique indexes in " + coll.getFullName() + " collection on " + id + " field"); } }
/** * Creates the unique index gfs. * * @param coll * the coll * @param id * the id */ private void createUniqueIndexGFS(DBCollection coll, String id) { try { coll.createIndex(new BasicDBObject("metadata." + id, 1), new BasicDBObject("unique", true)); } catch (MongoException ex) { throw new KunderaException("Error in creating unique indexes in " + coll.getFullName() + " collection on " + id + " field"); } }
/** * Drop the collection. */ @Override public void deleteSchema() throws GoraException { if (mongoClientColl == null) throw new GoraException( "Impossible to delete the schema as no schema is selected."); try { // If initialized, simply drop the collection mongoClientColl.drop(); LOG.debug( "Collection {} has been dropped for Mongo instance {}.", new Object[] { mongoClientColl.getFullName(), mongoClientDB.getMongo() }); } catch (Exception e) { throw new GoraException(e); } }
protected void ensureIndexes() throws MongoException { _version_1 = new BasicDBObject(getContextSubfield(__VERSION),1); DBObject idKey = BasicDBObjectBuilder.start().add("id", 1).get(); _dbSessions.createIndex(idKey, BasicDBObjectBuilder.start() .add("name", "id_1") .add("ns", _dbSessions.getFullName()) .add("sparse", false) .add("unique", true) .get()); DBObject versionKey = BasicDBObjectBuilder.start().add("id", 1).add("version", 1).get(); _dbSessions.createIndex(versionKey, BasicDBObjectBuilder.start() .add("name", "id_1_version_1") .add("ns", _dbSessions.getFullName()) .add("sparse", false) .add("unique", true) .get()); LOG.debug( "done ensure Mongodb indexes existing" ); //TODO perhaps index on expiry time? }