当前位置: 首页>>代码示例>>Java>>正文


Java CommandResult.getString方法代码示例

本文整理汇总了Java中com.mongodb.CommandResult.getString方法的典型用法代码示例。如果您正苦于以下问题:Java CommandResult.getString方法的具体用法?Java CommandResult.getString怎么用?Java CommandResult.getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mongodb.CommandResult的用法示例。


在下文中一共展示了CommandResult.getString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: status

import com.mongodb.CommandResult; //导入方法依赖的package包/类
@Override
public List<DependencyStatus> status() {
	//note failures are tested manually for now, if you make changes test
	//things still work
	//TODO TEST add tests exercising failures
	final String version;
	try {
		final CommandResult bi = gfs.getDB().command("buildInfo");
		version = bi.getString("version");
	} catch (MongoException e) {
		LoggerFactory.getLogger(getClass())
			.error("Failed to connect to MongoDB", e);
		return Arrays.asList(new DependencyStatus(false,
				"Couldn't connect to MongoDB: " + e.getMessage(),
				"GridFS", "Unknown"));
	}
	return Arrays.asList(
			new DependencyStatus(true, "OK", "GridFS", version));
}
 
开发者ID:kbase,项目名称:workspace_deluxe,代码行数:20,代码来源:GridFSBlobStore.java

示例2: status

import com.mongodb.CommandResult; //导入方法依赖的package包/类
public List<DependencyStatus> status() {
	//note failures are tested manually for now, if you make changes test
	//things still work
	//TODO TEST add tests exercising failures
	final List<DependencyStatus> deps = new LinkedList<>(blob.status());
	final String version;
	try {
		final CommandResult bi = wsmongo.command("buildInfo");
		version = bi.getString("version");
	} catch (MongoException e) {
		LoggerFactory.getLogger(getClass())
			.error("Failed to connect to MongoDB", e);
		deps.add(0, new DependencyStatus(false,
				"Couldn't connect to MongoDB: " + e.getMessage(),
				"MongoDB", "Unknown"));
		return deps;
	}
	deps.add(0, new DependencyStatus(true, "OK", "MongoDB", version));
	return deps;
}
 
开发者ID:kbase,项目名称:workspace_deluxe,代码行数:21,代码来源:MongoWorkspaceDB.java

示例3: check

import com.mongodb.CommandResult; //导入方法依赖的package包/类
@Override
protected Result check() throws Exception {
    final BasicDBObject command = new BasicDBObject("buildInfo", 1);
    final CommandResult commandResult = db.command(command);

    if (!commandResult.ok()) {
        return Result.unhealthy(commandResult.getErrorMessage());
    }

    final String version = commandResult.getString("version");
    return Result.healthy("Mongo server version: %s", version);
}
 
开发者ID:pgentile,项目名称:zucchini-ui,代码行数:13,代码来源:MongoHealthCheck.java

示例4: isInShardCluster

import com.mongodb.CommandResult; //导入方法依赖的package包/类
private boolean isInShardCluster(
    final CommandResult cr
) throws Exception {

    MongoServer ms = new MongoServer(getMyself(cr));
    final String host = ms.getHost();
    final int port = ms.getPort();

    boolean sharded = false;

    final String msg = cr.getString("msg");
    if ((msg != null) && msg.contains("isdbgrid")) {
        sharded = true;
    } else if (cr.getBoolean("ismaster")) {
        final CommandResult shardState =
            dbAdminCmd(host, port, "shardingState");
        // shardingState command only returns OK when server is in a sharded
        // cluster
        if (shardState.ok()) {
            if (shardState.getBoolean("enabled")) {
                sharded = true;
            }
        }
    }  else if (cr.containsField("primary")) {
        // we are in a replica set but not the primary,
        // check the primary to see if it is a shard member
        final String primary = cr.getString("primary");
        ms = new MongoServer(primary);
        final CommandResult priIsMaster =
            dbAdminCmd(ms.getHost(), ms.getPort(), "isMaster");
        sharded = isInShardCluster(priIsMaster);
    }
    return sharded;
}
 
开发者ID:CA-APM,项目名称:ca-apm-fieldpack-mongodb,代码行数:35,代码来源:Collector.java

示例5: getClusterNodeType

import com.mongodb.CommandResult; //导入方法依赖的package包/类
private String getClusterNodeType() throws Exception {

        final String host = getStringProp(DB_HOST_PROP);
        final int port = getIntProp(DB_PORT_PROP);

        String nodeType = null;

        final CommandResult isMaster = dbAdminCmd(host, port, "isMaster");
        if (isMaster.getBoolean("ismaster")) {
            final String msg = isMaster.getString("msg");
            if (msg != null && msg.contains("isdbgrid")) {
                nodeType = "shardRouter";
            } else {
                final CommandResult shardState =
                    dbAdminCmd(host, port, "shardingState");
                if (shardState.ok() && shardState.getBoolean("enabled")) {
                    if (isConfigServer(host, port)) {
                        nodeType = "shardConfigServer";
                    } else {
                        nodeType = "shardMember";
                    }
                }
            }
        } else if (isReplicaMember(isMaster)) {
            nodeType = "shardMember";
        }

        return nodeType;
    }
 
开发者ID:CA-APM,项目名称:ca-apm-fieldpack-mongodb,代码行数:30,代码来源:Collector.java

示例6: getConfigServersFromShard

import com.mongodb.CommandResult; //导入方法依赖的package包/类
private List<String> getConfigServersFromShard(
    final String host,
    final int port
) throws Exception {

    final List<String> cfgServers = new ArrayList<String>();

    String cHost = host;
    int cPort = port;

    final CommandResult isMaster = dbAdminCmd(cHost, cPort, "isMaster");

    // we can't run the DB command "shardingState" from a node
    // which isn't a master.  This should only apply to non-primary
    // replica members, so find the primary and run the command on it.
    if (! isMaster.getBoolean("ismaster")) {
        if (isMaster.containsField("primary")) {
            final String primary = isMaster.getString("primary");
            final MongoServer ms = new MongoServer(primary);
            cHost = ms.getHost();
            cPort = ms.getPort();
        }
    }

    CommandResult shardState =
        dbAdminCmd(cHost, cPort, "shardingState");

    if (shardState.ok()) {
        final String cfgSrvs =
            shardState.getString("configServer");
        addCommaSeparatedHosts(cfgServers, cfgSrvs);
    }
    return cfgServers;
}
 
开发者ID:CA-APM,项目名称:ca-apm-fieldpack-mongodb,代码行数:35,代码来源:ShardCluster.java

示例7: getStoreVersion

import com.mongodb.CommandResult; //导入方法依赖的package包/类
public String getStoreVersion() {
    CommandResult buildInfo = jongo.getDatabase().command("buildInfo");
    return buildInfo.getString("version");
}
 
开发者ID:dizitart,项目名称:nitrite-database,代码行数:5,代码来源:ReplicaStoreService.java

示例8: getServerVersion

import com.mongodb.CommandResult; //导入方法依赖的package包/类
/**
 * Returns server version.
 *
 * @return Server version.
 */
@Nonnull
public String getServerVersion() {
    final CommandResult result = db.doEval("db.version()");
    return result.getString("retval");
}
 
开发者ID:tomtom-international,项目名称:speedtools,代码行数:11,代码来源:MongoDB.java


注:本文中的com.mongodb.CommandResult.getString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。