Example usage for com.mongodb MongoClient unlock

List of usage examples for com.mongodb MongoClient unlock

Introduction

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

Prototype

@Deprecated
public DBObject unlock() 

Source Link

Document

Unlocks the database, allowing the write operations to go through.

Usage

From source file:com.edgytech.umongo.ServerPanel.java

License:Apache License

public void fsyncAndLock(ButtonBase button) {
    if (!UMongo.instance.getGlobalStore().confirmLockingOperation()) {
        return;/*from  w  w w.ja va 2  s .  co m*/
    }

    new DbJob() {

        @Override
        public Object doRun() throws IOException {
            MongoClient mongo = getServerNode().getServerMongoClient();
            boolean locked = mongo.isLocked();
            if (locked) {
                return mongo.unlock();
            }

            return mongo.fsyncAndLock();
        }

        @Override
        public String getNS() {
            return null;
        }

        @Override
        public String getShortName() {
            return "FSync And Lock";
        }

        @Override
        public void wrapUp(Object res) {
            try {
                // looks like the unlock doesnt take effect right away
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
            }

            super.wrapUp(res);
        }
    }.addJob();
}