public void shutdown() { client.close(); }
/** * Closes all resources associated with this instance. */ public void close() { client.close(); }
@Override public void close() { mongo.close(); }
@Override public void close() { mongo.close(); }
@Override public void close() { if (mongoClient != null) { mongoClient.close(); } }
@Override protected void destroyInstance(@Nullable MongoClient instance) throws Exception { if (instance != null) { instance.close(); } }
@Override protected void doClose() throws ElasticsearchException { synchronized ($lock) { for (MongoClient mongoClient : mongoClients.values()) { mongoClient.close(); } mongoClients.clear(); } }
@Override public void close() throws IOException { client.close(); } });
/** * Cleanup any state for this DB. Called once per DB instance; there is one DB * instance per client thread. */ @Override public void cleanup() throws DBException { if (INIT_COUNT.decrementAndGet() == 0) { try { mongoClient.close(); } catch (Exception e1) { System.err.println("Could not close MongoDB connection pool: " + e1.toString()); e1.printStackTrace(); return; } finally { database = null; mongoClient = null; } } }
@OnStopped public final void closeClient() { if (mongoClient != null) { mongoClient.close(); mongoClient = null; } }
@OnDisabled public void onDisable() { this.mongoClient.close(); }
@Override protected void closeClient() { getMongoClient().close(); }
@Signature public void close() { getWrappedObject().close(); } }
@OnStopped public final void closeClient() { if (mongoClient != null) { getLogger().info("Closing MongoClient"); mongoClient.close(); mongoClient = null; } }
public void shutdown() { close(); client.close(); server.shutdown(); } }
mongo.close(); mongo = null;
@After public void tearDown() { cleanup(); getMongoClient().close(); }
@Override protected void destroyInstance(@Nullable MongoClient instance) throws Exception { if (instance != null) { instance.close(); } }
@Override public void dispose() { dataStoreClient.close(); schemaStore.close(); super.dispose(); } }
MongoServer server = new MongoServer(new MemoryBackend()); // bind on a random local port InetSocketAddress serverAddress = server.bind(); MongoClient client = new MongoClient(new ServerAddress(serverAddress)); DBCollection coll = client.getDB("testdb").getCollection("testcoll"); // creates the database and collection in memory and inserts the object coll.insert(new BasicDBObject("key", "value")); assertEquals(1, collection.count()); assertEquals("value", collection.findOne().get("key")); client.close(); server.shutdownNow();