List of usage examples for com.mongodb ServerAddress getSocketAddress
public InetSocketAddress getSocketAddress()
From source file:com.edgytech.umongo.MongoPanel.java
License:Apache License
private String getServerAddressString(ServerAddress addr) { String ip = "unknown"; try {// w ww . ja va 2 s. com ip = addr.getSocketAddress().getAddress().toString(); } catch (UnknownHostException ex) { Logger.getLogger(MongoPanel.class.getName()).log(Level.WARNING, null, ex); } return addr.getHost() + ":" + addr.getPort() + " (" + ip + ")"; }
From source file:com.edgytech.umongo.RouterPanel.java
License:Apache License
@Override protected void updateComponentCustom(JPanel comp) { try {//from w w w .ja va 2 s .c o m ServerAddress addr = getRouterNode().getAddress(); setStringFieldValue(Item.host, addr.getHost() + ":" + addr.getPort()); setStringFieldValue(Item.address, addr.getSocketAddress().toString()); ((DocField) getBoundUnit(Item.shards)).setDoc(((RouterNode) node).shards); } 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 {//from w ww .ja va 2s. c o 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); } }