Example #1
0
BSONObj ShardType::toBSON() const {
    BSONObjBuilder builder;

    if (_name)
        builder.append(name(), getName());
    if (_host)
        builder.append(host(), getHost());
    if (_draining)
        builder.append(draining(), getDraining());
    if (_maxSizeMB)
        builder.append(maxSizeMB(), getMaxSizeMB());
    if (_tags)
        builder.append(tags(), getTags());

    return builder.obj();
}
Example #2
0
Status ShardType::validate() const {
    if (!_name.is_initialized() || _name->empty()) {
        return Status(ErrorCodes::NoSuchKey,
                      str::stream() << "missing " << name.name() << " field");
    }

    if (!_host.is_initialized() || _host->empty()) {
        return Status(ErrorCodes::NoSuchKey,
                      str::stream() << "missing " << host.name() << " field");
    }

    if (_maxSizeMB.is_initialized() && getMaxSizeMB() < 0) {
        return Status(ErrorCodes::BadValue, str::stream() << "maxSize can't be negative");
    }

    return Status::OK();
}
Example #3
0
BSONObj ShardType::toBSON() const {
    BSONObjBuilder builder;

    if (_name)
        builder.append(name(), getName());
    if (_host)
        builder.append(host(), getHost());
    if (_draining)
        builder.append(draining(), getDraining());
    if (_maxSizeMB)
        builder.append(maxSizeMB(), getMaxSizeMB());
    if (_tags)
        builder.append(tags(), getTags());
    if (_state)
        builder.append(state(), static_cast<std::underlying_type<ShardState>::type>(getState()));

    return builder.obj();
}