com.mongodb.MongoClient.close()

Here are the examples of the java api com.mongodb.MongoClient.close() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

81 Examples 7

19 Source : MongoConnectorBase.java
with BSD 3-Clause "New" or "Revised" License
from zzt93

@Override
public void close() {
    try {
        closeCursor();
        client.close();
    } catch (Throwable e) {
        logger.error("[Shutting down] failed", e);
        return;
    }
    MasterConnector.super.close();
}

19 Source : MongoTestSuit.java
with Apache License 2.0
from zpochen

@AfterClreplaced
public static void tearDownCluster() throws Exception {
    synchronized (MongoTestSuit.clreplaced) {
        if (initCount.decrementAndGet() == 0) {
            try {
                if (mongoClient != null) {
                    mongoClient.dropDatabase(EMPLOYEE_DB);
                    mongoClient.dropDatabase(DATATYPE_DB);
                    mongoClient.dropDatabase(DONUTS_DB);
                }
            } finally {
                if (mongoClient != null) {
                    mongoClient.close();
                }
                if (distMode) {
                    DistributedMode.cleanup();
                } else {
                    SingleMode.cleanup();
                }
            }
        }
    }
}

19 Source : MongoPersistentStoreProvider.java
with Apache License 2.0
from zpochen

@Override
public void close() {
    if (client != null) {
        client.close();
    }
}

19 Source : MongoBenchmark.java
with Apache License 2.0
from yametech

/**
 * benchmark之后执行
 */
@TearDown
public void after() {
    mongoClient.close();
}

19 Source : MongoConnector.java
with Apache License 2.0
from YagelNasManit

public void close() {
    client.close();
    connector = null;
}

19 Source : MongoDb.java
with Apache License 2.0
from XiaoMi

public boolean close() {
    try {
        logger.info("mongo client close");
        client.close();
        return true;
    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
        return false;
    }
}

19 Source : AbstractMongoProcessor.java
with Apache License 2.0
from wangrenlei

@OnStopped
public final void closeClient() {
    if (mongoClient != null) {
        getLogger().info("Closing MongoClient");
        mongoClient.close();
        mongoClient = null;
    }
}

19 Source : MongoRule.java
with Apache License 2.0
from vincentrussell

@Override
protected void after() {
    mongoClient.close();
    mongodProcess.stop();
    mongodExecutable.stop();
}

19 Source : MongoDBDataSource.java
with Apache License 2.0
from uavorg

@Override
public void stop() {
    mongo.close();
    super.stop();
}

19 Source : TestMongoIntegrationSmokeTest.java
with Apache License 2.0
from trinodb

@AfterClreplaced(alwaysRun = true)
public final void destroy() {
    server.close();
    client.close();
}

19 Source : MongoSession.java
with Apache License 2.0
from trinodb

public void shutdown() {
    client.close();
}

19 Source : DefaultClientSupplier.java
with GNU Affero General Public License v3.0
from torodb

@Override
public void close() {
    if (!closed) {
        closed = true;
        client.close();
        serverInstance.stopAsync();
        serverInstance.awaitTerminated();
        sqlService.stopAsync();
        sqlService.awaitTerminated();
    }
}

19 Source : MongoDBConnectionFactory.java
with Apache License 2.0
from teiid

@Override
public synchronized void close() throws IOException {
    if (mongoClient != null) {
        mongoClient.close();
    }
}

19 Source : MongoDBClient.java
with MIT License
from sun0x00

/**
 * 关闭客户端
 */
public void close() {
    if (mongoClient != null) {
        mongoClient.close();
        mongoClient = null;
    }
}

19 Source : MongoWrapper.java
with Apache License 2.0
from RADAR-base

@Override
public void close() {
    mongoClient.close();
    log.info("MongoDB connection is has been closed");
}

19 Source : MongoDatabasePolicy.java
with Apache License 2.0
from polypheny

@Override
protected void after() {
    client.close();
}

19 Source : TracingMongoClientTest.java
with Apache License 2.0
from opentracing-contrib

@Test
public void only_one_listener_added() throws UnknownHostException {
    MongoClient mongoClient = new TracingMongoClient(new TracingCommandListener.Builder(NoopTracerFactory.create()).build(), new MongoClientURI("mongodb://localhost"), MongoDriverInformation.builder().build());
    replacedertEquals(1, mongoClient.getMongoClientOptions().getCommandListeners().size());
    mongoClient.close();
}

19 Source : MongoTest.java
with Apache License 2.0
from opentracing-contrib

@Test
public void testSuccessDecorator() throws Exception {
    MongoClient mongoClient = new TracingMongoClient(new TracingCommandListener.Builder(mockTracer).withSpanDecorators(customDecorator).build(), new ServerAddress(mongodConfig.net().getServerAddress(), mongodConfig.net().getPort()));
    MongoDatabase db = mongoClient.getDatabase("test");
    MongoCollection<Doreplacedent> col = db.getCollection("testCol");
    col.insertOne(new Doreplacedent("testDoc", new Date()));
    mongoClient.close();
    List<MockSpan> finished = mockTracer.finishedSpans();
    replacedertEquals(1, finished.size());
    MockSpan span = finished.iterator().next();
    replacedertEquals(FOO, span.tags().get(FOO));
    replacedertEquals(BAR, span.tags().get(BAR));
    replacedertNull(span.tags().get(BAZ));
    replacedertNull(mockTracer.activeSpan());
}

19 Source : MongoTest.java
with Apache License 2.0
from opentracing-contrib

@Test
public void testExcludeAll() throws Exception {
    List<ExcludedCommand> excludedCommands = new ArrayList<>();
    ExcludedCommand excludedCommand = new ExcludedCommand();
    excludedCommand.put("getMore", BsonNull.VALUE);
    excludedCommand.put("collection", new BsonString("testCol"));
    excludedCommands.add(new ExcludedCommand("insert", new BsonString("testCol")));
    excludedCommands.add(new ExcludedCommand("find", BsonNull.VALUE));
    excludedCommands.add(excludedCommand);
    MongoClient mongoClient = new TracingMongoClient(new TracingCommandListener.Builder(mockTracer).withExcludedCommands(excludedCommands).build(), new ServerAddress(mongodConfig.net().getServerAddress(), mongodConfig.net().getPort()));
    MongoDatabase db = mongoClient.getDatabase("test");
    MongoCollection<Doreplacedent> col = db.getCollection("testCol");
    for (int i = 0; i < 100_000; i++) {
        col.insertOne(new Doreplacedent("testDoc", new Date()));
    }
    List<String> jsons = new ArrayList<>();
    final MongoCursor<Doreplacedent> cursor = col.find().iterator();
    while (cursor.hasNext()) {
        jsons.add(cursor.next().toJson());
    }
    replacedertEquals(100_000, jsons.size());
    mongoClient.close();
    List<MockSpan> finished = mockTracer.finishedSpans();
    replacedertEquals(0, finished.size());
    replacedertNull(mockTracer.activeSpan());
}

19 Source : MongoTest.java
with Apache License 2.0
from opentracing-contrib

@Test
public void sync() throws Exception {
    MongoClient mongoClient = new TracingMongoClient(new TracingCommandListener.Builder(mockTracer).build(), new ServerAddress(mongodConfig.net().getServerAddress(), mongodConfig.net().getPort()));
    MongoDatabase db = mongoClient.getDatabase("test");
    MongoCollection<Doreplacedent> col = db.getCollection("testCol");
    col.insertOne(new Doreplacedent("testDoc", new Date()));
    mongoClient.close();
    List<MockSpan> finished = mockTracer.finishedSpans();
    replacedertEquals(1, finished.size());
    checkSpans(finished);
    replacedertNull(mockTracer.activeSpan());
}

19 Source : MongoTest.java
with Apache License 2.0
from opentracing-contrib

@Test
public void testExcludeInsert() throws Exception {
    List<ExcludedCommand> excludedCommands = new ArrayList<>();
    ExcludedCommand excludedCommand = new ExcludedCommand();
    excludedCommand.put("insert", new BsonString("testCol"));
    excludedCommands.add(excludedCommand);
    MongoClient mongoClient = new TracingMongoClient(new TracingCommandListener.Builder(mockTracer).withExcludedCommands(excludedCommands).build(), new ServerAddress(mongodConfig.net().getServerAddress(), mongodConfig.net().getPort()));
    MongoDatabase db = mongoClient.getDatabase("test");
    MongoCollection<Doreplacedent> col = db.getCollection("testCol");
    col.insertOne(new Doreplacedent("testDoc", new Date()));
    mongoClient.close();
    List<MockSpan> finished = mockTracer.finishedSpans();
    replacedertEquals(0, finished.size());
    replacedertNull(mockTracer.activeSpan());
}

19 Source : MongoTest.java
with Apache License 2.0
from opentracing-contrib

@Test
public void testFailureDecorator() throws Exception {
    MongoClient mongoClient = new TracingMongoClient(new TracingCommandListener.Builder(mockTracer).withSpanDecorators(customDecorator).build(), new ServerAddress(mongodConfig.net().getServerAddress(), mongodConfig.net().getPort()));
    MongoDatabase db = mongoClient.getDatabase("test");
    try {
        // this is not a valid command
        db.runCommand(new Doreplacedent());
        fail();
    } catch (RuntimeException ignored) {
    }
    mongoClient.close();
    List<MockSpan> finished = mockTracer.finishedSpans();
    replacedertEquals(1, finished.size());
    MockSpan span = finished.iterator().next();
    replacedertEquals(FOO, span.tags().get(FOO));
    replacedertNull(span.tags().get(BAR));
    replacedertEquals(BAZ, span.tags().get(BAZ));
    replacedertNull(mockTracer.activeSpan());
}

19 Source : UserResourceTest.java
with Eclipse Public License 1.0
from OpenLiberty

@AfterClreplaced
public static void cleanup() {
    database.dropDatabase();
    mongo.close();
}

19 Source : LoginResourceTest.java
with Eclipse Public License 1.0
from OpenLiberty

@AfterClreplaced
public static void cleanup() {
    // Clean up the mess we made in the database.
    database.dropDatabase();
    mongo.close();
}

19 Source : OccasionResourceTest.java
with Eclipse Public License 1.0
from OpenLiberty

/**
 * Cleanup the database
 */
@AfterClreplaced
public static void cleanup() {
    String method = "cleanup";
    logger.entering(clazz, method);
    db.dropDatabase();
    mongoClient.close();
    logger.exiting(clazz, method);
}

19 Source : GroupResourceTest.java
with Eclipse Public License 1.0
from OpenLiberty

@AfterClreplaced
public static void teardown() {
    db.dropDatabase();
    mongo.close();
}

19 Source : MongoDBUtils.java
with Eclipse Public License 1.0
from OpenLiberty

private static boolean validateMongoConnectionAndSetConfig(ExternalTestService mongoService) {
    String method = "validateMongoConnectionAndSetConfig";
    MongoClient mongoClient = null;
    dbHost = mongoService.getAddress();
    int port = mongoService.getPort();
    dbPort = String.valueOf(port);
    File trustStore = null;
    MongoClientOptions.Builder optionsBuilder = new MongoClientOptions.Builder().connectTimeout(30000);
    try {
        trustStore = File.createTempFile("mongoTrustStore", "jks");
        Map<String, String> serviceProperties = mongoService.getProperties();
        // will be null if there's no auth for this server
        String preplacedword = serviceProperties.get(TEST_USERNAME + "_preplacedword");
        MongoClientOptions clientOptions = optionsBuilder.build();
        List<MongoCredential> credentials = Collections.emptyList();
        if (preplacedword != null) {
            MongoCredential credential = MongoCredential.createCredential(TEST_USERNAME, TEST_DATABASE, preplacedword.toCharArray());
            credentials = Collections.singletonList(credential);
            dbPwd = preplacedword;
        }
        Log.info(thisClreplaced, method, "Attempting to contact server " + dbHost + ":" + port + " with preplacedword " + (preplacedword != null ? "set" : "not set") + " and truststore " + "not set");
        mongoClient = new MongoClient(new ServerAddress(dbHost, port), credentials, clientOptions);
        mongoClient.getDB(TEST_DATABASE).getCollectionNames();
        dbName = TEST_DATABASE;
        mongoClient.close();
    } catch (Exception e) {
        // "Timed out" is checked in the output.txt and can cause a spurious failure
        String exceptionMsg = e.toString().replaceAll("Timed out", "Took too long");
        Log.info(thisClreplaced, method, "Couldn't create a connection to " + mongoService.getServiceName() + " on " + mongoService.getAddress() + ". " + exceptionMsg);
        mongoService.reportUnhealthy("Couldn't connect to server. Exception: " + exceptionMsg);
        return false;
    } finally {
        if (trustStore != null) {
            trustStore.delete();
        }
    }
    return true;
}

19 Source : MongoServerSelector.java
with Eclipse Public License 1.0
from OpenLiberty

/**
 * Creates a connection to the mongo server at the given location using the mongo java client.
 *
 * @param location
 * @param auth
 * @param encrypted
 * @return
 * @throws Exception
 */
private static boolean validateMongoConnection(ExternalTestService mongoService) {
    String method = "validateMongoConnection";
    MongoClient mongoClient = null;
    String host = mongoService.getAddress();
    int port = mongoService.getPort();
    File trustStore = null;
    MongoClientOptions.Builder optionsBuilder = new MongoClientOptions.Builder().connectTimeout(30000);
    try {
        trustStore = File.createTempFile("mongoTrustStore", "jks");
        Map<String, String> serviceProperties = mongoService.getProperties();
        // will be null if there's no auth for this server
        String preplacedword = serviceProperties.get(TEST_USERNAME + "_preplacedword");
        SSLSocketFactory sslSocketFactory = null;
        try {
            mongoService.writePropertyAsFile("ca_truststore", trustStore);
            sslSocketFactory = getSocketFactory(trustStore);
        } catch (IllegalStateException e) {
        // Ignore exception thrown if truststore is not present for this server
        // This indicates that we are not using SSL for this server and sslSocketFactory will be null
        }
        if (sslSocketFactory != null) {
            optionsBuilder.socketFactory(sslSocketFactory);
        }
        MongoClientOptions clientOptions = optionsBuilder.build();
        List<MongoCredential> credentials = Collections.emptyList();
        if (preplacedword != null) {
            MongoCredential credential = MongoCredential.createCredential(TEST_USERNAME, TEST_DATABASE, preplacedword.toCharArray());
            credentials = Collections.singletonList(credential);
        }
        Log.info(c, method, "Attempting to contact server " + host + ":" + port + " with preplacedword " + (preplacedword != null ? "set" : "not set") + " and truststore " + (sslSocketFactory != null ? "set" : "not set"));
        mongoClient = new MongoClient(new ServerAddress(host, port), credentials, clientOptions);
        mongoClient.getDB("default").getCollectionNames();
        mongoClient.close();
    } catch (Exception e) {
        Log.info(c, method, "Couldn't create a connection to " + mongoService.getServiceName() + " on " + mongoService.getAddress() + ". " + e.toString());
        mongoService.reportUnhealthy("Couldn't connect to server. Exception: " + e.toString());
        return false;
    } finally {
        if (trustStore != null) {
            trustStore.delete();
        }
    }
    return true;
}

19 Source : MongoWrapper.java
with GNU General Public License v3.0
from NightscoutFoundation

public void closeMongoDb() {
    if (mongoClient_ != null) {
        mongoClient_.close();
    }
}

19 Source : MongoDb310Test.java
with Apache License 2.0
from newrelic

@After
public void stopMongo() {
    if (mongoClient != null) {
        mongoClient.close();
    }
    if (mongodProcess != null) {
        mongodProcess.stop();
    }
    if (mongodExecutable != null) {
        mongodExecutable.stop();
    }
}

19 Source : MongodbHelper.java
with Apache License 2.0
from mtsoleimani

public void shutdown() {
    if (mongoClient != null)
        mongoClient.close();
    if (executor != null)
        executor.shutdown();
}

19 Source : MongoProducer.java
with Apache License 2.0
from MicroShed

public void close(@Disposes MongoClient toClose) {
    toClose.close();
}

19 Source : MongoMetricsCommandListenerTest.java
with Apache License 2.0
from micrometer-metrics

@AfterEach
void destroy() {
    if (mongo != null) {
        mongo.close();
    }
}

19 Source : MongoProxy.java
with GNU General Public License v3.0
from MarkBryanMilligan

@Override
public void shutdown() {
    client.close();
}

19 Source : DFMongoManager.java
with MIT License
from lostsky3000

protected void closePool(int id) {
    MongoClient cli = null;
    lockWrite.lock();
    try {
        cli = mapPool.remove(id);
    } finally {
        lockWrite.unlock();
    }
    if (cli != null) {
        cli.close();
        cli = null;
    }
}

19 Source : MongoVectorSpaceFactory.java
with MIT License
from Lambda-3

@Override
public void close() throws IOException {
    super.close();
    mongoClient.close();
}

19 Source : MongoIndraTranslator.java
with MIT License
from Lambda-3

@Override
public void close() throws IOException {
    mongoClient.close();
}

19 Source : MongoDataProxy.java
with GNU Affero General Public License v3.0
from KnowageLabs

private CommandResult loadData() {
    logger.debug("IN");
    CommandResult result = null;
    String clientUrl = dataSource.getUrlConnection();
    logger.debug("Getting the connection URL and db name");
    if (dataSource.getUser() != null && dataSource.getPwd() != null && dataSource.getUser().length() > 0 && dataSource.getPwd().length() > 0) {
        String authPart = "mongodb://" + dataSource.getUser() + ":" + dataSource.getPwd() + "@";
        clientUrl = clientUrl.replace("mongodb://", authPart);
    }
    logger.debug("MongoDB connection URI:" + clientUrl);
    MongoClientURI mongoClientURI = new MongoClientURI(clientUrl);
    MongoClient mongoClient = new MongoClient(new MongoClientURI(clientUrl));
    logger.debug("Connecting to mongodb");
    String databaseName = mongoClientURI.getDatabase();
    logger.debug("Database name: " + databaseName);
    try {
        logger.debug("Connecting to the db " + databaseName);
        DB database = mongoClient.getDB(databaseName);
        logger.debug("Executing the statement" + statement);
        result = database.doEval(getDecoredStatement());
    } catch (Exception e) {
        logger.error("Exception executing the MongoDataset", e);
        throw new SpagoBIRuntimeException("Exception executing the MongoDataset", e);
    } finally {
        logger.debug("Closing connection");
        mongoClient.close();
    }
    logger.debug("OUT");
    return result;
}

19 Source : DataSourceResource.java
with GNU Affero General Public License v3.0
from KnowageLabs

@POST
@Path("/test")
@Consumes(MediaType.APPLICATION_JSON)
@UserConstraint(functionalities = { SpagoBIConstants.DATASOURCE_MANAGEMENT })
public String testDataSource(IDataSource dataSource) throws Exception {
    logger.debug("IN");
    String url = dataSource.getUrlConnection();
    String user = dataSource.getUser();
    String pwd = dataSource.getPwd();
    String driver = dataSource.getDriver();
    String schemaAttr = dataSource.getSchemaAttribute();
    String jndi = dataSource.getJndi();
    IEngUserProfile profile = getUserProfile();
    String schema = (String) profile.getUserAttribute(schemaAttr);
    logger.debug("schema:" + schema);
    if (jndi != null && jndi.length() > 0) {
        String jndiName = schema == null ? jndi : jndi + schema;
        try {
            logger.debug("Lookup JNDI name:" + jndiName);
            Context ctx = new InitialContext();
            javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup(jndiName);
            try (Connection connection = ds.getConnection()) {
                logger.debug("Connection performed successfully");
            }
        } catch (AuthenticationException e) {
            logger.error("Error while attempting to reacquire the authentication information on provided JNDI name", e);
            throw new SpagoBIServiceException(SERVICE_NAME, e);
        } catch (NamingException e) {
            logger.error("Error with provided JNDI name. Can't find the database with that name.", e);
            throw new SpagoBIServiceException(SERVICE_NAME, e);
        } catch (Exception e) {
            logger.error("Error with provided JNDI name.", e);
            throw new SpagoBIServiceException(SERVICE_NAME, e);
        }
    } else {
        if (driver.toLowerCase().contains("mongo")) {
            logger.debug("Checking the connection for MONGODB");
            MongoClient mongoClient = null;
            try {
                int databaseNameStart = url.lastIndexOf("/");
                if (databaseNameStart < 0) {
                    logger.error("Error connecting to the mongoDB. No database selected");
                }
                String databaseUrl = url.substring(0, databaseNameStart);
                String databaseName = url.substring(databaseNameStart + 1);
                mongoClient = new MongoClient(databaseUrl);
                DB database = mongoClient.getDB(databaseName);
                database.getCollectionNames();
                logger.debug("Connection OK");
                return new JSONObject().toString();
            } catch (Exception e) {
                logger.error("Error connecting to the mongoDB", e);
            } finally {
                if (mongoClient != null) {
                    mongoClient.close();
                }
            }
        } else {
            try {
                Clreplaced.forName(driver);
            } catch (ClreplacedNotFoundException e) {
                logger.error("Driver not found", e);
                throw new SpagoBIRestServiceException("Driver not found: " + driver, buildLocaleFromSession(), e);
            }
            try (Connection connection = DriverManager.getConnection(url, user, pwd)) {
                logger.debug("Connection performed successfully");
            }
        }
    }
    return new JSONObject().toString();
}

19 Source : OplogClient.java
with Apache License 2.0
from kekingcn

@Override
public void close() throws Exception {
    mongoClient.close();
}

19 Source : MongoManaged.java
with Apache License 2.0
from katharsis-project

public void stop() throws Exception {
    mongoClient.close();
}

19 Source : DBTool.java
with MIT License
from jzyong

// GEN-LAST:event_openMenuItemActionPerformed
private void javaFieldBtnActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_javaFieldBtnActionPerformed
    // 显示对应表的Java字段定义
    List<String> selectSheets = sheetJList.getSelectedValuesList();
    if (selectSheets == null || selectSheets.size() < 1) {
        logTextArea.append("请选择表单\r\n");
        return;
    }
    selectSheets.forEach(sheetName -> {
        try {
            Args.Four<List<String>, List<String>, List<String>, List<String>> metaData = ExcelUtil.getMetaData(sheetNameFiles.get(sheetName).getAbsolutePath(), sheetName);
            for (int i = 0; i < metaData.a().size(); i++) {
                // 不显示客户端字段
                if ("client".equalsIgnoreCase(metaData.d().get(i))) {
                    continue;
                }
                StringBuilder sb = new StringBuilder();
                sb.append("/**").append(metaData.c().get(i)).append("*/").append("\r\n");
                sb.append("private ");
                String filedType = metaData.b().get(i).toLowerCase();
                if ("string".equals(filedType) || "date".equals(filedType) || "object".equals(filedType)) {
                    // 首字母大写
                    filedType = StringUtil.upFirstChar(filedType);
                } else if ("array".equals(filedType)) {
                    filedType = "List<Object>";
                }
                sb.append(filedType).append(" ").append(metaData.a().get(i)).append(";");
                logTextArea.append(sb.toString() + "\r\n");
            }
            logTextArea.append("\r\n");
        } catch (Exception e) {
            LOGGER.error("更新数据", e);
        }
    });
    if (mongoClient != null) {
        mongoClient.close();
    }
}

19 Source : DBTool.java
with MIT License
from jzyong

// </editor-fold>//GEN-END:initComponents
private void insertDataBtnActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_insertDataBtnActionPerformed
    List<String> selectSheets = sheetJList.getSelectedValuesList();
    if (selectSheets == null || selectSheets.size() < 1) {
        logTextArea.append("请选择表单\r\n");
        return;
    }
    // 更新数据库配置
    selectSheets.forEach(sheetName -> {
        try {
            String log = MongoUtil.insertConfigData(getMongoClient(), sheetNameFiles.get(sheetName).getAbsolutePath(), sheetName, getDBConfig().getDbName());
            logTextArea.append(log + "\r\n");
        } catch (Exception e) {
            LOGGER.error("更新数据", e);
        }
    });
    if (mongoClient != null) {
        mongoClient.close();
    }
    // 加载服务器配置
    // String loadConfigUrl = getDBConfig().getLoadConfigUrl();
    List<String> loadConfigUrls = getDBConfig().getLoadConfigUrls();
    for (String loadConfigUrl : loadConfigUrls) {
        if (loadConfigUrl != null && !loadConfigUrl.equalsIgnoreCase("")) {
            String log = HttpUtil.URLGet(loadConfigUrl);
            logTextArea.append("游戏服-" + getDBConfig().getDbName() + " " + loadConfigUrl + ":" + log + "更新配置成功\r\n");
        }
    }
}

19 Source : MongoPersistentStore.java
with Apache License 2.0
from jackhallam

/**
 * Closes this stream and releases any system resources replacedociated
 * with it. If the stream is already closed then invoking this
 * method has no effect.
 *
 * <p> As noted in {@link AutoCloseable#close()}, cases where the
 * close may fail require careful attention. It is strongly advised
 * to relinquish the underlying resources and to internally
 * <em>mark</em> the {@code Closeable} as closed, prior to throwing
 * the {@code IOException}.
 *
 * @throws IOException if an I/O error occurs
 */
@Override
public void close() throws IOException {
    if (mongoClient != null) {
        mongoClient.close();
    }
}

19 Source : MongoStore.java
with Apache License 2.0
from iotaledger

@Override
public void shutdown() {
    collection = null;
    database = null;
    if (client != null) {
        client.close();
    }
}

19 Source : ExecutionApp.java
with Apache License 2.0
from IBM

private static void closeConnection(MongoClient mongo) {
    mongo.close();
}

19 Source : MongoDbUtil.java
with Apache License 2.0
from i-Cell-Mobilsoft-Open-Source

/**
 * Closes mongo client connection.
 *
 * @param mongoClient
 *            mongo DB client
 * @throws BaseException
 *             if any exception occurs during close
 * @see MongoClient#close()
 */
public static void close(MongoClient mongoClient) throws BaseException {
    if (mongoClient != null) {
        try {
            mongoClient.close();
        } catch (Exception e) {
            throw new TechnicalException(CoffeeFaultType.OPERATION_FAILED, "Failed to close mongoDb client: " + e.getLocalizedMessage(), e);
        }
    }
}

19 Source : DefaultHygieiaServiceImpl.java
with Apache License 2.0
from Hygieia

@Override
public boolean closeConnection(MongoClient mongoClient) {
    try {
        if (mongoClient != null) {
            mongoClient.close();
            return true;
        }
    } catch (Exception e) {
        LOG.error(e.getMessage());
    }
    return false;
}

19 Source : MongoDbSinkTask.java
with Apache License 2.0
from hpgrahsl

@Override
public void stop() {
    LOGGER.info("stopping MongoDB sink task");
    mongoClient.close();
}

19 Source : MongoDbSessionStoreTest.java
with Apache License 2.0
from finos

@AfterClreplaced
public static void teardown() {
    server.shutdown();
    client.close();
}

See More Examples