Author: mreutegg
Date: Wed Jul 20 14:07:12 2016
New Revision: 1753519
URL: http://svn.apache.org/viewvc?rev=1753519&view=rev
Log:
OAK-4111: Include mongo version details in log
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
URL:
http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java?rev=1753519&r1=1753518&r2=1753519&view=diff
==============================================================================
---
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
(original)
+++
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/mongo/MongoDocumentStore.java
Wed Jul 20 14:07:12 2016
@@ -43,6 +43,7 @@ import javax.annotation.Nullable;
import com.google.common.base.Stopwatch;
import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.UncheckedExecutionException;
@@ -133,6 +134,11 @@ public class MongoDocumentStore implemen
public static final int IN_CLAUSE_BATCH_SIZE = 500;
+ private static final ImmutableSet<String> SERVER_DETAIL_FIELD_NAMES
+ = ImmutableSet.<String>builder()
+ .add("host", "process", "connections", "repl", "storageEngine",
"mem")
+ .build();
+
private final DBCollection nodes;
private final DBCollection clusterNodes;
private final DBCollection settings;
@@ -226,7 +232,8 @@ public class MongoDocumentStore implemen
private boolean hasModifiedIdCompoundIndex = true;
public MongoDocumentStore(DB db, DocumentMK.Builder builder) {
- String version = checkVersion(db);
+ CommandResult serverStatus = db.command("serverStatus");
+ String version = checkVersion(serverStatus);
metadata = ImmutableMap.<String,String>builder()
.put("type", "mongo")
.put("version", version)
@@ -284,14 +291,17 @@ public class MongoDocumentStore implemen
this.nodeLocks = new StripedNodeDocumentLocks();
this.nodesCache = builder.buildNodeDocumentCache(this, nodeLocks);
- LOG.info("Configuration maxReplicationLagMillis {}, " +
- "maxDeltaForModTimeIdxSecs {}, disableIndexHint {}, {}",
- maxReplicationLagMillis, maxDeltaForModTimeIdxSecs,
- disableIndexHint, db.getWriteConcern());
+ LOG.info("Connected to MongoDB {} with maxReplicationLagMillis {}, " +
+ "maxDeltaForModTimeIdxSecs {}, disableIndexHint {}, " +
+ "{}, serverStatus {}",
+ version, maxReplicationLagMillis, maxDeltaForModTimeIdxSecs,
+ disableIndexHint, db.getWriteConcern(),
+ serverDetails(serverStatus));
}
- private static String checkVersion(DB db) {
- String version = db.command("buildInfo").getString("version");
+ @Nonnull
+ private static String checkVersion(CommandResult serverStatus) {
+ String version = serverStatus.getString("version");
Matcher m = Pattern.compile("^(\\d+)\\.(\\d+)\\..*").matcher(version);
if (!m.matches()) {
throw new IllegalArgumentException("Malformed MongoDB version: " +
version);
@@ -310,6 +320,18 @@ public class MongoDocumentStore implemen
return version;
}
+ @Nonnull
+ private static String serverDetails(CommandResult serverStatus) {
+ Map<String, Object> details = Maps.newHashMap();
+ for (String key : SERVER_DETAIL_FIELD_NAMES) {
+ Object value = serverStatus.get(key);
+ if (value != null) {
+ details.put(key, value);
+ }
+ }
+ return details.toString();
+ }
+
@Override
public void finalize() throws Throwable {
super.finalize();