Configurable write concernt for mstore mongodb driver.

This commit is contained in:
Olof Larsson 2014-04-05 11:06:45 +02:00
parent 3f3016c27e
commit d6ef55d465
2 changed files with 10 additions and 2 deletions

View File

@ -10,6 +10,7 @@ import org.bukkit.permissions.Permissible;
import com.massivecraft.mcore.store.Entity;
import com.massivecraft.mcore.util.MUtil;
import com.massivecraft.mcore.util.PermUtil;
import com.massivecraft.mcore.xlib.mongodb.WriteConcern;
public class MCoreConf extends Entity<MCoreConf>
{
@ -61,6 +62,11 @@ public class MCoreConf extends Entity<MCoreConf>
public List<String> getDeleteFiles() { return this.deleteFiles == null ? new ArrayList<String>() : new ArrayList<String>(this.deleteFiles); }
public void setDeleteFiles(List<String> deleteFiles) { this.deleteFiles = deleteFiles == null ? new ArrayList<String>() : new ArrayList<String>(deleteFiles); this.changed(); }
// Used in the MongoDB mstore driver.
private WriteConcern mongoDbWriteConcern = WriteConcern.ACKNOWLEDGED;
public WriteConcern getMongoDbWriteConcern() { return this.mongoDbWriteConcern; }
public void setMongoDbWriteConcern(WriteConcern mongoDbWriteConcern) { this.mongoDbWriteConcern = mongoDbWriteConcern; this.changed(); }
// -------------------------------------------- //
// HELP ACCESS
// -------------------------------------------- //

View File

@ -9,6 +9,7 @@ import java.util.Set;
import java.util.AbstractMap.SimpleEntry;
import java.util.Map.Entry;
import com.massivecraft.mcore.MCoreConf;
import com.massivecraft.mcore.xlib.gson.JsonElement;
import com.massivecraft.mcore.xlib.mongodb.BasicDBObject;
import com.massivecraft.mcore.xlib.mongodb.DB;
@ -168,7 +169,7 @@ public class DriverMongo extends DriverAbstract
GsonMongoConverter.gson2MongoObject(data, dbo);
dbcoll.save(dbo);
dbcoll.save(dbo, MCoreConf.get().getMongoDbWriteConcern());
return mtime;
}
@ -176,7 +177,8 @@ public class DriverMongo extends DriverAbstract
@Override
public void delete(Coll<?> coll, String id)
{
fixColl(coll).remove(new BasicDBObject(ID_FIELD, id));
DBCollection dbcoll = fixColl(coll);
dbcoll.remove(new BasicDBObject(ID_FIELD, id), MCoreConf.get().getMongoDbWriteConcern());
}
//----------------------------------------------//