use of com.mongodb.WriteConcern in project jackrabbit-oak by apache.
the class MemoryDocumentStore method setReadWriteMode.
@Override
public void setReadWriteMode(String readWriteMode) {
if (readWriteMode == null || readWriteMode.equals(lastReadWriteMode)) {
return;
}
lastReadWriteMode = readWriteMode;
try {
Map<String, String> map = Splitter.on(", ").withKeyValueSeparator(":").split(readWriteMode);
String read = map.get("read");
if (read != null) {
ReadPreference readPref = ReadPreference.valueOf(read);
if (!readPref.equals(this.readPreference)) {
this.readPreference = readPref;
}
}
String write = map.get("write");
if (write != null) {
WriteConcern writeConcern = WriteConcern.valueOf(write);
if (!writeConcern.equals(this.writeConcern)) {
this.writeConcern = writeConcern;
}
}
} catch (Exception e) {
// unsupported or parse error - ignore
}
}
use of com.mongodb.WriteConcern in project jackrabbit-oak by apache.
the class BlobThroughPutTest method performBenchMark_WriteConcern.
@Ignore
@Test
public void performBenchMark_WriteConcern() throws UnknownHostException, InterruptedException {
Mongo mongo = new Mongo(new DBAddress(remoteServer));
final DB db = mongo.getDB(TEST_DB1);
final DBCollection nodes = db.getCollection("nodes");
final DBCollection blobs = db.getCollection("blobs");
int readers = 0;
int writers = 2;
for (WriteConcern wc : namedConcerns.keySet()) {
prepareDB(nodes, blobs);
final Benchmark b = new Benchmark(nodes, blobs);
Result r = b.run(readers, writers, true, wc);
results.add(r);
}
prepareDB(nodes, blobs);
dumpResult();
}
use of com.mongodb.WriteConcern in project jackrabbit-oak by apache.
the class MongoDBExceptionTest method before.
@Before
public void before() throws Exception {
OakFongo fongo = new OakFongo("fongo") {
@Override
protected void beforeExecuteBulkWriteOperation(boolean ordered, Boolean bypassDocumentValidation, List<?> writeRequests, WriteConcern aWriteConcern) {
maybeThrow();
}
@Override
protected void beforeFindAndModify(DBObject query, DBObject fields, DBObject sort, boolean remove, DBObject update, boolean returnNew, boolean upsert) {
maybeThrow();
}
@Override
protected void beforeUpdate(DBObject q, DBObject o, boolean upsert, boolean multi, WriteConcern concern, DBEncoder encoder) {
maybeThrow();
}
@Override
protected void beforeFind(DBObject query, DBObject projection) {
maybeThrow();
}
private void maybeThrow() {
if (exceptionMsg != null) {
throw new MongoException(exceptionMsg);
}
}
};
store = new MongoDocumentStore(fongo.getMongo(), "oak", new DocumentMK.Builder());
}
use of com.mongodb.WriteConcern in project jackrabbit-oak by apache.
the class MongoConnection method hasWriteConcern.
/**
* Returns {@code true} if the given {@code uri} has a write concern set.
* @param uri the URI to check.
* @return {@code true} if the URI has a write concern set, {@code false}
* otherwise.
*/
public static boolean hasWriteConcern(@Nonnull String uri) {
MongoClientOptions.Builder builder = MongoClientOptions.builder();
builder.writeConcern(WC_UNKNOWN);
WriteConcern wc = new MongoClientURI(checkNotNull(uri), builder).getOptions().getWriteConcern();
return !WC_UNKNOWN.equals(wc);
}
use of com.mongodb.WriteConcern in project pinpoint by naver.
the class MongoWriteConcernMapper method buildWriteConcern.
private Map<WriteConcern, String> buildWriteConcern() {
Map<WriteConcern, String> writeConcernMap = new HashMap<>();
for (final Field f : WriteConcern.class.getFields()) {
if (Modifier.isStatic(f.getModifiers()) && f.getType().equals(WriteConcern.class) && f.getAnnotation(Deprecated.class) == null) {
String value = f.getName();
try {
WriteConcern key = (WriteConcern) f.get(null);
writeConcernMap.put(key, value);
} catch (IllegalAccessException e) {
PLogger logger = PLoggerFactory.getLogger(this.getClass());
logger.warn("WriteConcern access error Caused by:" + e.getMessage(), e);
}
}
}
return writeConcernMap;
}
Aggregations