List of usage examples for com.mongodb DBCollection getReadPreference
public ReadPreference getReadPreference()
From source file:com.ebay.cloud.cms.dal.persistence.MongoExecutor.java
License:Apache License
private static void logMongoAction(PersistenceContext context, String operName, long start, DBCollection dbCollection, DBObject queryObject, DBObject bodyObject, SearchOption option, Integer queryResultSize, String statusMsg) { long end = System.currentTimeMillis(); long cost = end - start; //mili seconds //recording the time cost in mongo DB context.addDBTimeCost(cost);/*from www . j a va 2 s .co m*/ if (logger.isDebugEnabled()) { String costStr = Long.toString(cost); String queryObjectStr = "{}"; if (queryObject != null) { queryObjectStr = queryObject.toString(); } String bodyObjectStr = "{}"; if (bodyObject != null) { bodyObjectStr = bodyObject.toString(); } String sortObjectStr = "{}"; if (option != null && option.hasSort()) { sortObjectStr = option.getSort().toString(); } StringBuilder optionBuilder = new StringBuilder("{"); if (option != null && (option.hasSkip() || option.hasLimit())) { optionBuilder.append("\"skip\" : "); optionBuilder.append(option.getSkip()); optionBuilder.append(", \"limit\" : "); optionBuilder.append(option.getLimit()); } optionBuilder.append("}"); StringBuilder readPref = new StringBuilder("{"); StringBuilder writeCon = new StringBuilder("{"); String dbName = ""; String[] args; if (dbCollection != null) { readPref.append(dbCollection.getReadPreference().getName()); writeCon.append(dbCollection.getWriteConcern().toString()); dbName = dbCollection.getFullName(); } readPref.append("}"); writeCon.append("}"); StringBuilder queryResult = new StringBuilder(); if (queryResultSize != null) { queryResult.append("queryResultSize=").append(queryResultSize); } args = new String[] { operName, statusMsg, costStr, dbName, queryObjectStr, bodyObjectStr, sortObjectStr, optionBuilder.toString(), readPref.toString(), writeCon.toString(), queryResult.toString() }; logger.debug( "operation={}|status={}|cost={}ms|collection={}|query={}|body={}|sort={}|option={}|readPrefernce={}|writeConcern={}|{}", args); } }
From source file:com.edgytech.umongo.CollectionPanel.java
License:Apache License
@Override protected void updateComponentCustom(JPanel old) { try {// w w w. ja v a 2 s . c o m DBCollection collection = getCollectionNode().getCollection(); setStringFieldValue(Item.name, collection.getName()); setStringFieldValue(Item.fullName, collection.getFullName()); setStringFieldValue(Item.queryOptions, MongoUtils.queryOptionsToString(collection.getOptions())); ((DocField) getBoundUnit(Item.writeConcern)).setDoc(collection.getWriteConcern().getCommand()); ((DocField) getBoundUnit(Item.readPreference)).setDoc(collection.getReadPreference().toDBObject()); ((CmdField) getBoundUnit(Item.stats)).updateFromCmd(collection); } catch (Exception e) { UMongo.instance.showError(this.getClass().getSimpleName() + " update", e); } }
From source file:com.edgytech.umongo.CollectionPanel.java
License:Apache License
public void readWriteOptions(ButtonBase button) { final DBCollection col = getCollectionNode().getCollection(); OptionDialog od = UMongo.instance.getGlobalStore().getOptionDialog(); od.update(col.getOptions(), col.getWriteConcern(), col.getReadPreference()); if (!od.show()) { return;/*from w w w . j a va2s . c o m*/ } col.setOptions(od.getQueryOptions()); col.setWriteConcern(od.getWriteConcern()); col.setReadPreference(od.getReadPreference()); refresh(); }
From source file:org.jongo.MongoCollection.java
License:Apache License
public MongoCollection(DBCollection dbCollection, Mapper mapper) { this(dbCollection, mapper, dbCollection.getWriteConcern(), dbCollection.getReadPreference()); }