Example usage for com.mongodb MongoClient fsync

List of usage examples for com.mongodb MongoClient fsync

Introduction

In this page you can find the example usage for com.mongodb MongoClient fsync.

Prototype

@Deprecated
public CommandResult fsync(final boolean async) 

Source Link

Document

Forces the master server to fsync the RAM data to disk This is done automatically by the server at intervals, but can be forced for better reliability.

Usage

From source file:com.softinstigate.restheart.Bootstrapper.java

License:Open Source License

private static void stopServer() {
    logger.info("stopping RESTHeart");
    logger.info("waiting for pending request to complete (up to 1 minute)");

    try {//from   w  w w . j  a  v a  2 s. com
        hanldersPipe.shutdown();
        hanldersPipe.awaitShutdown(60 * 1000); // up to 1 minute
    } catch (InterruptedException ie) {
        logger.error("error while waiting for pending request to complete", ie);
    }

    if (server != null) {
        try {
            server.stop();
        } catch (Throwable t) {
            logger.error("error stopping undertow server", t);
        }
    }

    try {
        MongoClient client = MongoDBClientSingleton.getInstance().getClient();
        client.fsync(false);
        client.close();
    } catch (Throwable t) {
        logger.error("error flushing and clonsing the mongo cliet", t);
    }

    tmpExtractedFiles.keySet().forEach(k -> {
        try {
            ResourcesExtractor.deleteTempDir(k, tmpExtractedFiles.get(k));
        } catch (URISyntaxException | IOException ex) {
            logger.error("error cleaning up temporary directory {}", tmpExtractedFiles.get(k).toString(), ex);
        }
    });

    logger.info("RESTHeart stopped");
}

From source file:org.apache.gora.mongodb.store.MongoStore.java

License:Apache License

/**
 * Ensure the data is synced to disk./* ww w  .  ja  v a  2s.  c o  m*/
 */
@Override
public void flush() {
    for (MongoClient client : mapsOfClients.values()) {
        client.fsync(false);
        LOG.info("Forced synced of database for Mongo instance {}.", new Object[] { client });
    }
}