use of org.apache.jackrabbit.oak.plugins.document.Document in project jackrabbit-oak by apache.
the class MongoDocumentStoreMetrics method getStats.
private CollectionStats getStats(Collection<? extends Document> c) throws MongoException {
CollectionStats stats = new CollectionStats();
BasicDBObject result = new BasicDBObject(db.runCommand(new org.bson.Document("collStats", c.toString())));
stats.count = result.getLong("count", 0);
stats.size = result.getLong("size", 0);
stats.storageSize = result.getLong("storageSize", 0);
stats.totalIndexSize = result.getLong("totalIndexSize", 0);
return stats;
}
use of org.apache.jackrabbit.oak.plugins.document.Document in project jackrabbit-oak by apache.
the class RDBDocumentStore method insertDocuments.
private <T extends Document> boolean insertDocuments(Collection<T> collection, List<T> documents) {
Connection connection = null;
RDBTableMetaData tmd = getTable(collection);
try {
connection = this.ch.getRWConnection();
Set<String> insertedKeys = db.insert(connection, tmd, documents);
connection.commit();
return insertedKeys.size() == documents.size();
} catch (SQLException ex) {
this.ch.rollbackConnection(connection);
List<String> ids = new ArrayList<String>();
for (T doc : documents) {
ids.add(doc.getId());
}
String message = String.format("insert of %s failed", ids);
LOG.debug(message, ex);
// collect additional exceptions
String messages = LOG.isDebugEnabled() ? RDBJDBCTools.getAdditionalMessages(ex) : "";
// see whether a DATA error was involved
boolean dataRelated = false;
SQLException walk = ex;
while (walk != null && !dataRelated) {
dataRelated = RDBJDBCTools.matchesSQLState(walk, "22", "72");
walk = walk.getNextException();
}
if (dataRelated) {
String id = null;
int longest = 0, longestChars = 0;
for (Document d : documents) {
String data = ser.asString(d, tmd.getColumnOnlyProperties());
byte[] bytes = asBytes(data);
if (bytes.length > longest) {
longest = bytes.length;
longestChars = data.length();
id = d.getId();
}
}
String m = String.format(" (potential cause: long data for ID %s - longest octet DATA size in Java characters: %d, in octets: %d, computed character limit: %d)", id, longest, longestChars, tmd.getDataLimitInOctets() / CHAR2OCTETRATIO);
messages += m;
}
if (!messages.isEmpty()) {
LOG.debug("additional diagnostics: " + messages);
}
throw handleException(message, ex, collection, ids);
} finally {
this.ch.closeConnection(connection);
}
}
Aggregations