/** * Closes all resources associated with this instance, in particular any open network connections. Once called, this instance and any * databases obtained from it can no longer be used. */ public void close() { super.close(); }
/** * Attempts to find an existing MongoClient instance matching that URI in the holder, and returns it if exists. Otherwise creates a * new Mongo instance based on this URI and adds it to the holder. * * @param uri the Mongo URI * @return the client * @throws MongoException if there's a failure */ public Mongo connect(final MongoClientURI uri) { String key = toKey(uri); Mongo client = clients.get(key); if (client == null) { Mongo newbie = new MongoClient(uri); client = clients.putIfAbsent(key, newbie); if (client == null) { client = newbie; } else { newbie.close(); } } return client; }
@Override public void destroy() { indexManager.close(); if (schemaManager != null) { schemaManager.dropSchema(); } if (mongoDB != null) { logger.info("Closing connection to mongodb."); mongoDB.getMongo().close(); logger.info("Closed connection to mongodb."); } else { logger.warn("Can't close connection to MONGODB, it was already disconnected"); } externalProperties = null; schemaManager = null; }
/** * Closes the underlying Mongo instance */ public void close() { if (mongo != null) { mongo.close(); } } }
/** * Closes all resources associated with this instance, in particular any open network connections. Once called, this instance and any * databases obtained from it can no longer be used. */ public void close() { super.close(); }
@Override public void run() { if(mongo != null) { mongo.close(); mongo = null; } }
@Override public void run() { if(mongo != null) { mongo.close(); mongo = null; } }
@Override public void close() throws IOException { if (mongo != null) { mongo.close(); } } }
/** * @see org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent) */ @Override public void onApplicationEvent(ContextClosedEvent event) { if(this.mongo != null) { this.mongo.close(); this.mongo = null; } }
/** * @see org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent) */ @Override public void onApplicationEvent(ContextClosedEvent event) { if(this.mongo != null) { this.mongo.close(); this.mongo = null; } }
@Override public void shutdown() { mongo.close(); } }
@Teardown public void teardown() { mongo.close(); }
public void clear() { if(log.isDebugEnabled()) { log.debug("clearing"); } mongo.close(); //there is no harm in trying to clear up mongo = null; } }
public static void close(final Mongo client) { MongoClientURI uri = URI_MAP.get().remove(client); if (uri != null) { MongoClient remove; remove = CLIENTS.get().remove(uri); if (remove != client) { throw new IllegalStateException("different clients found"); } client.close(); } }
/** * Disconnect the whole mongo instances. */ public static void dispose() { disconnect(); Collection<Mongo> mongos = mongosCache.values(); for (Mongo mongo : mongos) { mongo.close(); } mongosCache.clear(); }
@Override protected void tearDown() throws Exception { if (mockMongo != null) mockMongo.stop(); if (mongo != null) mongo.close(); }
@Override protected void doStop() throws Exception { super.doStop(); if (mongoConnection != null) { LOG.debug("Closing connection"); mongoConnection.close(); } }
public void close() { if (db != null) { db.getMongo().close(); } }
@Override public void dispose() { if (LOG.isDebugEnabled()) { LOG.debug("MongoDB time: " + timeSum); } nodes.getDB().getMongo().close(); }
/** * Close the AQ native session and the database connection. */ public void close() throws ResourceException { try { this.db.getMongo().close(); } catch (Exception exception) { ResourceException resourceException = new ResourceException(exception.toString()); resourceException.initCause(exception); throw resourceException; } }