Permalink
Browse files

Manage sort for stats.

  • Loading branch information...
1 parent 2c57472 commit 79d4385d32a49ab616852e25d751c8a1455168c3 @angelozerr angelozerr committed Aug 10, 2012
Showing with 1,024 additions and 184 deletions.
  1. +43 −0 com.mongodb.tools/src/com/mongodb/tools/driver/StatsHelper.java
  2. +31 −8 ...ensagres.mongodb.ide.core/src/fr/opensagres/mongodb/ide/core/model/stats/CollectionListStats.java
  3. +102 −12 fr.opensagres.mongodb.ide.core/src/fr/opensagres/mongodb/ide/core/model/stats/CollectionStats.java
  4. +30 −0 fr.opensagres.mongodb.ide.core/src/fr/opensagres/mongodb/ide/core/model/stats/IndexStats.java
  5. BIN fr.opensagres.mongodb.ide.launching/bin/fr/opensagres/mongodb/ide/launching/internal/Activator.class
  6. BIN ...agres.mongodb.ide.launching/bin/fr/opensagres/mongodb/ide/launching/internal/ImageResources.class
  7. BIN ...ongodb.ide.launching/bin/fr/opensagres/mongodb/ide/launching/internal/ServerLauncherManager.class
  8. BIN ...odb.ide.launching/bin/fr/opensagres/mongodb/ide/launching/internal/dialogs/AddRuntimeDialog.class
  9. BIN ...gres/mongodb/ide/launching/internal/launchConfigurations/ProcessLaunchConfigurationDelegate.class
  10. BIN .../mongodb/ide/launching/internal/launchConfigurations/mongo/MongoLaunchConfigurationDelegate.class
  11. BIN ...agres/mongodb/ide/launching/internal/launchConfigurations/mongo/MongoLaunchConfigurationTab.class
  12. BIN .../mongodb/ide/launching/internal/launchConfigurations/mongo/MongoLaunchConfigurationTabGroup.class
  13. BIN ...ongodb/ide/launching/internal/launchConfigurations/mongod/MongodLaunchConfigurationDelegate.class
  14. BIN ...res/mongodb/ide/launching/internal/launchConfigurations/mongod/MongodLaunchConfigurationTab.class
  15. BIN ...ongodb/ide/launching/internal/launchConfigurations/mongod/MongodLaunchConfigurationTabGroup.class
  16. BIN .../bin/fr/opensagres/mongodb/ide/launching/internal/launchConfigurations/mongod/MongodProcess.class
  17. BIN ...e.launching/bin/fr/opensagres/mongodb/ide/launching/internal/preferences/AbstractTableBlock.class
  18. BIN ...s/mongodb/ide/launching/internal/preferences/InstalledRuntimesBlock$RuntimesContentProvider.class
  19. BIN ...unching/bin/fr/opensagres/mongodb/ide/launching/internal/preferences/InstalledRuntimesBlock.class
  20. BIN ...ing/bin/fr/opensagres/mongodb/ide/launching/internal/preferences/MongoRuntimePreferencePage.class
  21. BIN ...nsagres.mongodb.ide.ui/bin/fr/opensagres/mongodb/ide/ui/editors/collection/CollectionEditor.class
  22. BIN fr.opensagres.mongodb.ide.ui/bin/fr/opensagres/mongodb/ide/ui/internal/Messages.class
  23. +13 −7 fr.opensagres.mongodb.ide.ui/bin/fr/opensagres/mongodb/ide/ui/internal/Messages.properties
  24. BIN fr.opensagres.mongodb.ide.ui/icons/obj16/index.png
  25. BIN fr.opensagres.mongodb.ide.ui/icons/obj16/index.png-old
  26. BIN fr.opensagres.mongodb.ide.ui/icons/obj16/index.png-old2
  27. +2 −2 fr.opensagres.mongodb.ide.ui/plugin.properties
  28. +21 −23 fr.opensagres.mongodb.ide.ui/src/fr/opensagres/mongodb/ide/ui/ServerUI.java
  29. +9 −8 fr.opensagres.mongodb.ide.ui/src/fr/opensagres/mongodb/ide/ui/dialogs/StackTraceErrorDialog.java
  30. +1 −0 ...ensagres.mongodb.ide.ui/src/fr/opensagres/mongodb/ide/ui/editors/collection/CollectionEditor.java
  31. +29 −0 fr.opensagres.mongodb.ide.ui/src/fr/opensagres/mongodb/ide/ui/editors/collection/IndexesPage.java
  32. +1 −0 fr.opensagres.mongodb.ide.ui/src/fr/opensagres/mongodb/ide/ui/editors/database/DatabaseEditor.java
  33. +2 −1 fr.opensagres.mongodb.ide.ui/src/fr/opensagres/mongodb/ide/ui/editors/database/OverviewPage.java
  34. +44 −58 fr.opensagres.mongodb.ide.ui/src/fr/opensagres/mongodb/ide/ui/editors/database/StatsPage.java
  35. +8 −3 fr.opensagres.mongodb.ide.ui/src/fr/opensagres/mongodb/ide/ui/internal/Messages.java
  36. +13 −7 fr.opensagres.mongodb.ide.ui/src/fr/opensagres/mongodb/ide/ui/internal/Messages.properties
  37. +13 −0 fr.opensagres.mongodb.ide.ui/src/fr/opensagres/mongodb/ide/ui/viewers/ViewerHelper.java
  38. +3 −3 ...godb.ide.ui/src/fr/opensagres/mongodb/ide/ui/viewers/editor/ControlEditorColumnLabelProvider.java
  39. +24 −8 ...pensagres.mongodb.ide.ui/src/fr/opensagres/mongodb/ide/ui/viewers/editor/GradientProgressBar.java
  40. +13 −9 ...de.ui/src/fr/opensagres/mongodb/ide/ui/viewers/editor/GradientProgressBarColumnLabelProvider.java
  41. +6 −0 ...res.mongodb.ide.ui/src/fr/opensagres/mongodb/ide/ui/viewers/editor/IProgressBarValueProvider.java
  42. +119 −0 ...ide.ui/src/fr/opensagres/mongodb/ide/ui/viewers/sort/AbstractBeanSortColumnSelectionListener.java
  43. +32 −0 ...odb.ide.ui/src/fr/opensagres/mongodb/ide/ui/viewers/sort/BeanSortTreeColumnSelectionListener.java
  44. +167 −0 fr.opensagres.mongodb.ide.ui/src/fr/opensagres/mongodb/ide/ui/viewers/sort/BeanUtils.java
  45. +72 −0 fr.opensagres.mongodb.ide.ui/src/fr/opensagres/mongodb/ide/ui/viewers/sort/BeanViewerComparator.java
  46. +43 −0 ...mongodb.ide.ui/src/fr/opensagres/mongodb/ide/ui/viewers/stats/StatsAvgObjColumnLabelProvider.java
  47. +8 −6 ...gres.mongodb.ide.ui/src/fr/opensagres/mongodb/ide/ui/viewers/{ → stats}/StatsContentProvider.java
  48. +11 −13 ...odb.ide.ui/src/fr/opensagres/mongodb/ide/ui/viewers/{ → stats}/StatsCountColumnLabelProvider.java
  49. +54 −0 ...godb.ide.ui/src/fr/opensagres/mongodb/ide/ui/viewers/stats/StatsIndexSizeColumnLabelProvider.java
  50. +9 −3 ...godb.ide.ui/src/fr/opensagres/mongodb/ide/ui/viewers/{ → stats}/StatsNameColumnLabelProvider.java
  51. +43 −0 ...ongodb.ide.ui/src/fr/opensagres/mongodb/ide/ui/viewers/stats/StatsPaddingColumnLabelProvider.java
  52. +13 −13 ...godb.ide.ui/src/fr/opensagres/mongodb/ide/ui/viewers/{ → stats}/StatsSizeColumnLabelProvider.java
  53. +45 −0 ...ongodb.ide.ui/src/fr/opensagres/mongodb/ide/ui/viewers/stats/StatsStorageColumnLabelProvider.java
@@ -0,0 +1,43 @@
+package com.mongodb.tools.driver;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.CommandResult;
+
+public class StatsHelper {
+
+ private static final String SIZE = "size";
+ private static final String COUNT = "count";
+ private static final String STORAGE = "storageSize";
+ private static final String AVG_OBJ = "avgObjSize";
+ private static final String PADDING = "paddingFactor";
+ private static final String INDEX_SIZES = "indexSizes";
+
+ public static double getSize(CommandResult stats) {
+ return stats.getDouble(SIZE);
+ }
+
+ public static double getCount(CommandResult stats) {
+ return stats.getDouble(COUNT);
+ }
+
+ public static double getStorage(CommandResult stats) {
+ return stats.getDouble(STORAGE);
+ }
+
+ public static double getAvgObj(CommandResult stats) {
+ return stats.getDouble(AVG_OBJ);
+ }
+
+ public static double getPadding(CommandResult stats) {
+ return stats.getDouble(PADDING);
+ }
+
+ public static BasicDBObject getIndexSizes(CommandResult stats) {
+ return (BasicDBObject) stats.get(INDEX_SIZES);
+ }
+
+ public static String formatAsBytes(double value) {
+ return String.valueOf(value);
+ }
+
+}
@@ -11,32 +11,55 @@
private double totalSize;
private double totalCount;
+ private double totalStorage;
+ private double totalAvgObj;
+ private double totalPadding;
+ private double totalIndexSize;
public CollectionListStats(int size) {
super(size);
this.totalSize = 0;
+ this.totalIndexSize = 0;
}
@Override
public boolean add(CollectionStats stats) {
- double size = stats.getSize();
- totalSize += size;
- double count = stats.getCount();
- totalCount += count;
+ totalSize += stats.getSize();
+ totalCount += stats.getCount();
+ totalStorage += stats.getStorage();
+ totalAvgObj += stats.getAvgObj();
+ totalPadding += stats.getPadding();
+ totalIndexSize += stats.getTotalIndexSize();
return super.add(stats);
}
public double getTotalSize() {
return totalSize;
}
+ public double getTotalCount() {
+ return totalCount;
+ }
+
+ public double getTotalStorage() {
+ return totalStorage;
+ }
+
+ public double getTotalAvgObj() {
+ return totalAvgObj;
+ }
+
+ public double getTotalPadding() {
+ return totalPadding;
+ }
+
+ public double getTotalIndexSize() {
+ return totalIndexSize;
+ }
+
public void addCollection(Collection collection)
throws UnknownHostException, MongoException {
add(new CollectionStats(this, collection));
}
- public double getTotalCount() {
- return totalCount;
- }
-
}
@@ -1,35 +1,76 @@
package fr.opensagres.mongodb.ide.core.model.stats;
import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Set;
+import com.mongodb.BasicDBObject;
import com.mongodb.CommandResult;
import com.mongodb.MongoException;
+import com.mongodb.tools.driver.StatsHelper;
import fr.opensagres.mongodb.ide.core.model.Collection;
-public class CollectionStats {
+public class CollectionStats extends ArrayList<IndexStats> {
+
+ public static final String NAME_PROPERTY = "name";
+ public static final String COUNT_PROPERTY = "count";
+ public static final String SIZE_PROPERTY = "size";
+ public static final String STORAGE_PROPERTY = "storage";
+ public static final String TOTAL_INDEX_SIZE_PROPERTY = "totalIndexSize";
+ public static final String AVGOBJ_PROPERTY = "avgObj";
+ public static final String PADDING_PROPERTY = "padding";
private final CollectionListStats listStats;
private final Collection collection;
- private double size;
private double count;
+ private double size;
+ private double storage;
+ private double totalIndexSize;
+ private double avgObj;
+ private double padding;
public CollectionStats(CollectionListStats listStats, Collection collection)
throws UnknownHostException, MongoException {
+ this.totalIndexSize = 0;
this.listStats = listStats;
this.collection = collection;
CommandResult stats = collection.getShellCommandManager()
.getDBCollectionGetStats(collection.getDBCollection());
- size = stats.getDouble("size");
- count = stats.getDouble("count");
-
- // System.err.println(stats);
+ // Collection stats
+ this.size = StatsHelper.getSize(stats);
+ this.count = StatsHelper.getCount(stats);
+ this.storage = StatsHelper.getStorage(stats);
+ this.avgObj = StatsHelper.getAvgObj(stats);
+ this.padding = StatsHelper.getPadding(stats);
+ // Indexes stats
+ BasicDBObject indexes = StatsHelper.getIndexSizes(stats);
+ Set<String> indexNames = indexes.keySet();
+ for (String id : indexNames) {
+ addIndex(id, indexes.getInt(id));
+ }
}
public Collection getCollection() {
return collection;
}
+ public String getName() {
+ return collection.getName();
+ }
+
+ public double getCount() {
+ return count;
+ }
+
+ public double getPercentCount() {
+ double totalCount = listStats.getTotalCount();
+ if (count == 0) {
+ return 0;
+ }
+ return (count / totalCount) * 100;
+ }
+
public double getSize() {
return size;
}
@@ -42,15 +83,64 @@ public double getPercentSize() {
return (size / totalSize) * 100;
}
- public double getCount() {
- return count;
+ public double getStorage() {
+ return storage;
}
- public double getPercentCount() {
- double totalCount = listStats.getTotalCount();
- if (count == 0) {
+ public double getPercentStorage() {
+ double totalStorage = listStats.getTotalStorage();
+ if (storage == 0) {
return 0;
}
- return (size / totalCount) * 100;
+ return (storage / totalStorage) * 100;
+ }
+
+ public double getAvgObj() {
+ return avgObj;
+ }
+
+ public double getPercentAvgObj() {
+ double totalAvgObj = listStats.getTotalAvgObj();
+ if (avgObj == 0) {
+ return 0;
+ }
+ return (avgObj / totalAvgObj) * 100;
+ }
+
+ public double getPadding() {
+ return padding;
+ }
+
+ public double getPercentPadding() {
+ double totalPadding = listStats.getTotalPadding();
+ if (padding == 0) {
+ return 0;
+ }
+ return (padding / totalPadding) * 100;
+ }
+
+ @Override
+ public boolean add(IndexStats stats) {
+ double size = stats.getIndexSize();
+ totalIndexSize += size;
+ return super.add(stats);
+ }
+
+ public double getTotalIndexSize() {
+ return totalIndexSize;
+ }
+
+ public void addIndex(String id, double indexSize)
+ throws UnknownHostException, MongoException {
+ add(new IndexStats(this, id, indexSize));
+ }
+
+ public CollectionListStats getListStats() {
+ return listStats;
+ }
+
+ public double getPercentIndexSize() {
+ double totalSize = listStats.getTotalIndexSize();
+ return (totalIndexSize / totalSize) * 100;
}
}
@@ -0,0 +1,30 @@
+package fr.opensagres.mongodb.ide.core.model.stats;
+
+public class IndexStats {
+
+ private final CollectionStats collectionStats;
+ private final String id;
+ private final double indexSize;
+
+ public IndexStats(CollectionStats collectionStats, String id, double indexSize) {
+ this.collectionStats = collectionStats;
+ this.id = id;
+ this.indexSize = indexSize;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public double getIndexSize() {
+ return indexSize;
+ }
+
+ public double getPercentIndexSize() {
+ double totalSize = collectionStats.getListStats().getTotalIndexSize();
+ if (indexSize == 0) {
+ return 0;
+ }
+ return (indexSize / totalSize) * 100;
+ }
+}
@@ -76,19 +76,21 @@ databaseEditorOverviewShellDescription=You can connect you to Mongo console with
DatabaseEditor_OverviewPage_Shell_connection=Connection\:
databaseEditorOverviewStatsSection=Stats
databaseEditorOvervieStatsDescription=Show stats of collection and indexes
+DatabaseEditor_OverviewPage_DatabaseContent_title=Database content
+DatabaseEditor_OverviewPage_DatabaseContent_content=<form>\
+<p>The content of the Mongo database is made up of several sections:</p>\
+<li style="image" value="stats_page" bindent="5"><a href="stats">Stats</a>: list of collection and indexes stats.</li>\
+<li style="image" value="users_page" bindent="5"><a href="users">Users</a>: list the users.</li>\
+<li style="image" value="indexes_page" bindent="5"><a href="indexes">Indexes</a>: list the indexes.</li>\
+</form>
StatsPage_title=Stats
UsersPage_title=Users
UsersEditor_UsersPage_UsersMasterDetailsBlock_title=List of users
UsersEditor_UsersPage_UsersMasterDetailsBlock_desc=Add/remove users
UserEditor_UsersPage_UserDetailsPage_title=User detail
UserEditor_UsersPage_UserDetailsPage_desc=Fill user
UserEditor_UsersPage_UserDetailsPage_userLabel_label=Name
-DatabaseEditor_OverviewPage_DatabaseContent_title=Database content
-DatabaseEditor_OverviewPage_DatabaseContent_content=<form>\
-<p>The content of the Mongo database is made up of several sections:</p>\
-<li style="image" value="stats_page" bindent="5"><a href="stats">Stats</a>: list of collection and indexes stats.</li>\
-<li style="image" value="users_page" bindent="5"><a href="users">Users</a>: list the users.</li>\
-</form>
+IndexesPage_title=Indexes
# Collection editor
DocumentsPage_title=Documents
@@ -106,4 +108,8 @@ columnUsername=Username
columnReadonly=Readonly?
columnName=Name
columnSize=Size
-columnCount=Count
+columnCount=Count
+columnStorage=Storage
+columnAvgObj=AvgObj
+columnPadding=Padding
+columnIndexSize=Index
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
@@ -19,8 +19,8 @@ perspectiveName=MongoDB IDE
# Views
Mongo.category=MongoDB IDE
-ServerExplorer.name=MongoDB Explorer
-ShellCommandsView.name=Shell Commands.
+ServerExplorer.name=MongoDB
+ShellCommandsView.name=Shell Commands
# Wizard
NewServerWizard.name=New Server
Oops, something went wrong.

0 comments on commit 79d4385

Please sign in to comment.