Example usage for com.mongodb MongoClient getMaxBsonObjectSize

List of usage examples for com.mongodb MongoClient getMaxBsonObjectSize

Introduction

In this page you can find the example usage for com.mongodb MongoClient getMaxBsonObjectSize.

Prototype

@Deprecated
@SuppressWarnings("deprecation")
public int getMaxBsonObjectSize() 

Source Link

Document

Gets the maximum size for a BSON object supported by the current master server.

Usage

From source file:com.edgytech.umongo.MongoPanel.java

License:Apache License

@Override
protected void updateComponentCustom(JPanel old) {
    try {/* www  .  j  a  va 2 s  .co m*/
        MongoClient mongo = getMongoNode().getMongoClient();
        setStringFieldValue(Item.version, mongo.getVersion());

        ServerAddress master = mongo.getAddress();
        if (master != null) {
            setStringFieldValue(Item.masterServer, getServerAddressString(master));
        }
        List<ServerAddress> addrs = mongo.getAllAddress();
        String html = "<html>";
        for (ServerAddress addr : addrs) {
            html += getServerAddressString(addr) + "<br/>";
        }
        html += "</html>";
        setStringFieldValue(Item.seedServers, html);

        addrs = mongo.getServerAddressList();
        html = "<html>";
        for (ServerAddress addr : addrs) {
            //                String ports = MongoUtils.makeInfoString("used", mongo.getConnector().getDBPortPool(addr).inUse(),
            //                        "available", mongo.getConnector().getDBPortPool(addr).available(),
            //                        "created", mongo.getConnector().getDBPortPool(addr).everCreated());
            String txt = getServerAddressString(addr);
            html += txt + "<br/>";
        }
        setStringFieldValue(Item.activeServers, html);

        setStringFieldValue(Item.queryOptions, MongoUtils.queryOptionsToString(mongo.getOptions()));
        ((DocField) getBoundUnit(Item.writeConcern)).setDoc(mongo.getWriteConcern().getCommand());
        ((DocField) getBoundUnit(Item.readPreference)).setDoc(mongo.getReadPreference().toDBObject());
        setStringFieldValue(Item.maxObjectSize, String.valueOf(mongo.getMaxBsonObjectSize()));
    } catch (Exception e) {
        UMongo.instance.showError(this.getClass().getSimpleName() + " update", e);
    }
}

From source file:com.edgytech.umongo.ServerPanel.java

License:Apache License

@Override
protected void updateComponentCustom(JPanel comp) {
    try {/* ww  w  . j a va 2s.  co  m*/
        ServerNode node = getServerNode();
        if (node.isConfig) {
            ((Menu) getBoundUnit(Item.replica)).enabled = false;
        }

        MongoClient svrMongo = node.getServerMongoClient();
        ServerAddress addr = getServerNode().getServerAddress();
        if (addr != null) {
            setStringFieldValue(Item.host, addr.toString());
            setStringFieldValue(Item.address, addr.getSocketAddress().toString());
        }

        CommandResult res = svrMongo.getDB("local").command("isMaster");
        boolean master = res.getBoolean("ismaster");
        String replication = MongoUtils.makeInfoString("master", master, "secondary",
                res.getBoolean("secondary"), "passive", res.getBoolean("passive"));
        setStringFieldValue(Item.replication, replication);
        ((Text) getBoundUnit(Item.replication)).showIcon = master;

        setStringFieldValue(Item.maxObjectSize, String.valueOf(svrMongo.getMaxBsonObjectSize()));

        //            ((CmdField) getBoundUnit(Item.serverStatus)).updateFromCmd(svrMongo);
        //
        //            DBObject svrStatus = ((DocField) getBoundUnit(Item.serverStatus)).getDoc();
        //            boolean dur = svrStatus.containsField("dur");
        //            ((Text)getBoundUnit(Item.journaling)).setStringValue(dur ? "On" : "Off");
        //            ((Text)getBoundUnit(Item.journaling)).showIcon = dur;
    } catch (Exception e) {
        UMongo.instance.showError(this.getClass().getSimpleName() + " update", e);
    }
}