File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,25 @@ public static boolean serverIsAtLeastVersion(double version) {
62
62
return Double .parseDouble (serverVersion .substring (0 , 3 )) >= version ;
63
63
}
64
64
65
+ public static boolean isStandalone () {
66
+ return !isReplicaSet () && !isSharded ();
67
+ }
68
+
69
+ public static boolean isSharded () {
70
+ CommandResult isMasterResult = runIsMaster ();
71
+ Object msg = isMasterResult .get ("msg" );
72
+ return msg != null && msg .equals ("isdbgrid" );
73
+ }
74
+
75
+ public static boolean isReplicaSet () {
76
+ return runIsMaster ().get ("setName" ) != null ;
77
+ }
78
+
79
+ private static CommandResult runIsMaster () {
80
+ // Check to see if this is a replica set... if not, get out of here.
81
+ return getMongoClient ().getDB ("admin" ).command (new BasicDBObject ("ismaster" , 1 ));
82
+ }
83
+
65
84
static class ShutdownHook extends Thread {
66
85
@ Override
67
86
public void run () {
You can’t perform that action at this time.
0 commit comments