use of com.mongodb.WriteConcern in project spring-data-mongodb by spring-projects.
the class PerformanceTests method executeWithWriteConcerns.
private void executeWithWriteConcerns(WriteConcernCallback callback) {
Constants constants = new Constants(WriteConcern.class);
for (String constantName : constants.getNames(null)) {
if (IGNORED_WRITE_CONCERNS.contains(constantName)) {
continue;
}
WriteConcern writeConcern = (WriteConcern) constants.asObject(constantName);
setupCollections();
callback.doWithWriteConcern(constantName, writeConcern);
}
}
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;
}
use of com.mongodb.WriteConcern in project morphia by mongodb.
the class Mapper method getWriteConcern.
/**
* Gets the write concern for entity or returns the default write concern for this datastore
*
* @param clazz the class to use when looking up the WriteConcern
* @return the write concern for the type
* @morphia.internal
*/
@Nullable
public WriteConcern getWriteConcern(Class clazz) {
WriteConcern wc = null;
EntityModel entityModel = getEntityModel(clazz);
if (entityModel != null) {
final Entity entityAnn = entityModel.getEntityAnnotation();
if (entityAnn != null && !entityAnn.concern().isEmpty()) {
wc = WriteConcern.valueOf(entityAnn.concern());
}
}
return wc;
}
Aggregations