Permalink
Browse files

issue66: shard list should be dropdown in movechunk

  • Loading branch information...
1 parent e0adc9f commit 7ee84e7fcace4f0b15fa8de865b8dfbcf50f12e4 @agirbal committed Mar 19, 2012
@@ -423,15 +423,15 @@
</MenuItem>
<MenuSeparator/>
<MenuItem id="findChunks" call="findChunks"/>
- <MenuItem id="moveChunk" call="moveChunk">
+ <MenuItem id="moveChunk" call="moveChunk" showDialog="false">
<FormDialog>
- <com.edgytech.jmongobrowser.DocBuilderField id="mvckQuery" label="Chunk Query" toolTipText="Query to find the chunk by"/>
- <TextField id="mvckToShard" label="To Shard" nonEmpty="true" toolTipText="Name of shard to send the chunk to"/>
+ <com.edgytech.jmongobrowser.DocBuilderField id="mvckQuery" label="Chunk Query" toolTipText="Query to find the chunk by" nonEmpty="true"/>
+ <ComboBox id="mvckToShard" label="To Shard" items="None" toolTipText="Shard to send the chunk to"/>
</FormDialog>
</MenuItem>
<MenuItem id="splitChunk" call="splitChunk">
<FormDialog>
- <com.edgytech.jmongobrowser.DocBuilderField id="spckQuery" label="Chunk Query" toolTipText="Query to find the chunk by"/>
+ <com.edgytech.jmongobrowser.DocBuilderField id="spckQuery" label="Chunk Query" toolTipText="Query to find the chunk by" nonEmpty="true"/>
<CheckBox id="spckOnValue" label="Split on Value" value="false" toolTipText="If true, split chunk on provided query value, otherwise split chunk in the middle"/>
</FormDialog>
</MenuItem>
@@ -613,6 +613,7 @@
<Div zone="NORTH" gap="true" bgColor="255;255;255">
<Text id="host" field="true"/>
<Text id="address" field="true"/>
+ <com.edgytech.jmongobrowser.DocField id="shards"/>
</Div>
</Zone>
</com.edgytech.jmongobrowser.RouterPanel>
@@ -970,6 +970,23 @@ public void findChunks() {
}
public void moveChunk() {
+ FormDialog dialog = (FormDialog) ((MenuItem) getBoundUnit(Item.moveChunk)).getDialog();
+ ComboBox combo = (ComboBox) getBoundUnit(Item.mvckToShard);
+ combo.value = 0;
+ BasicDBList shards = getCollectionNode().getDbNode().getMongoNode().getShards();
+ if (!shards.isEmpty()) {
+ String[] items = new String[shards.size()];
+ for (int i = 0; i < shards.size(); ++i) {
+ DBObject shard = (DBObject) shards.get(i);
+ items[i] = (shard.get("_id")).toString();
+ }
+ combo.items = items;
+ combo.structureComponent();
+ }
+
+ if (!dialog.show())
+ return;
+
BasicDBObject cmd = new BasicDBObject("moveChunk", getCollectionNode().getCollection().getFullName());
DBObject query = ((DocBuilderField) getBoundUnit(Item.mvckQuery)).getDBObject();
cmd.append("find", query);
@@ -4,6 +4,8 @@
*/
package com.edgytech.jmongobrowser;
+import com.edgytech.swingfast.XmlUnit;
+import com.mongodb.BasicDBList;
import com.mongodb.CommandResult;
import com.mongodb.DB;
import com.mongodb.Mongo;
@@ -76,7 +78,7 @@ protected void populateChildren() {
}
}
- // get local and remove dbs
+ // get local and remote dbs
for (DB db : mongo.getUsedDatabases()) {
addChild(new DbNode(db));
}
@@ -89,4 +91,11 @@ protected void updateNode(List<ImageIcon> overlays) {
label += " (" + list.size() + ")";
}
+ BasicDBList getShards() {
+ XmlUnit child = getChild(0);
+ if (child instanceof RouterNode) {
+ return ((RouterNode)child).getShards();
+ }
+ return null;
+ }
}
@@ -4,6 +4,7 @@
*/
package com.edgytech.jmongobrowser;
+import com.edgytech.swingfast.XmlUnit;
import com.mongodb.BasicDBList;
import com.mongodb.BasicDBObject;
import com.mongodb.CommandResult;
@@ -25,6 +26,7 @@
Mongo mongo;
ServerAddress addr;
+ BasicDBList shards;
public RouterNode(ServerAddress addr, Mongo mongo) throws IOException, SAXException {
this.addr = addr;
@@ -35,7 +37,7 @@ public RouterNode(ServerAddress addr, Mongo mongo) throws IOException, SAXExcept
@Override
protected void populateChildren() {
CommandResult res = mongo.getDB("admin").command("listShards");
- BasicDBList shards = (BasicDBList) res.get("shards");
+ shards = (BasicDBList) res.get("shards");
if (shards == null)
return;
@@ -85,4 +87,8 @@ public Mongo getMongo() {
protected void updateNode(List<ImageIcon> overlays) {
label = getAddress().toString();
}
+
+ BasicDBList getShards() {
+ return shards;
+ }
}
@@ -42,6 +42,7 @@
refresh,
host,
address,
+ shards,
listShards,
addShard,
asHost,
@@ -76,6 +77,8 @@ protected void updateComponentCustom(JPanel comp) {
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);
+
final Mongo mongo = getRouterNode().getMongo();
setBooleanFieldValue(Item.autoBalance, MongoUtils.isBalancerOn(mongo));
} catch (Exception e) {
@@ -101,7 +104,7 @@ public void addShard() {
server = replSetName + "/" + server;
final BasicDBObject cmd = new BasicDBObject("addshard", server);
- if (shardName != null)
+ if (!shardName.isEmpty())
cmd.put("name", shardName);
if (maxsize > 0)
cmd.put("maxSize", maxsize);

0 comments on commit 7ee84e7

Please sign in to comment.