List of usage examples for com.mongodb WriteConcern equals
@Override public boolean equals(final Object o)
From source file:com.navercorp.pinpoint.plugin.mongo.interceptor.MongoCUDSessionInterceptor.java
License:Apache License
public String getWriteConcern0(WriteConcern writeConcern) { for (final Field f : WriteConcern.class.getFields()) { if (Modifier.isStatic(f.getModifiers()) && f.getType().equals(WriteConcern.class)) { try { if (writeConcern.equals(f.get(null))) { return f.getName().toUpperCase(); }//from w w w.j a v a 2 s . c o m } catch (IllegalAccessException e) { //throw new RuntimeException(e);//TODO } } } return null; }
From source file:org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore.java
License:Apache License
@Override public void setReadWriteMode(String readWriteMode) { if (readWriteMode == null || readWriteMode.equals(lastReadWriteMode)) { return;/* w ww . jav a 2 s . c o m*/ } 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 } }
From source file:org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore.java
License:Apache License
@Override public void setReadWriteMode(String readWriteMode) { if (readWriteMode == null || readWriteMode.equals(lastReadWriteMode)) { return;//ww w.j a v a 2 s .c o m } lastReadWriteMode = readWriteMode; try { String rwModeUri = readWriteMode; if (!readWriteMode.startsWith("mongodb://")) { rwModeUri = String.format("mongodb://localhost/?%s", readWriteMode); } MongoClientURI uri = new MongoClientURI(rwModeUri); ReadPreference readPref = uri.getOptions().getReadPreference(); if (!readPref.equals(nodes.getReadPreference())) { nodes.setReadPreference(readPref); LOG.info("Using ReadPreference {} ", readPref); } WriteConcern writeConcern = uri.getOptions().getWriteConcern(); if (!writeConcern.equals(nodes.getWriteConcern())) { nodes.setWriteConcern(writeConcern); LOG.info("Using WriteConcern " + writeConcern); } } catch (Exception e) { LOG.error("Error setting readWriteMode " + readWriteMode, e); } }