Skip to content

Commit

Permalink
Issue #5108, ordered connections by last command
Browse files Browse the repository at this point in the history
  • Loading branch information
lvca committed Oct 12, 2015
1 parent 99e19bf commit 9596bcf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Expand Up @@ -369,7 +369,7 @@ public void listConnections() throws IOException {


final List<OIdentifiable> resultSet = new ArrayList<OIdentifiable>(); final List<OIdentifiable> resultSet = new ArrayList<OIdentifiable>();


final Collection<Map<String, Object>> connections = serverInfo.field("connections"); final List<Map<String, Object>> connections = serverInfo.field("connections");
for (Map<String, Object> conn : connections) { for (Map<String, Object> conn : connections) {
final ODocument row = new ODocument(); final ODocument row = new ODocument();


Expand All @@ -378,12 +378,21 @@ public void listConnections() throws IOException {
if (commandDetail != null && ((String) conn.get("commandDetail")).length() > 1) if (commandDetail != null && ((String) conn.get("commandDetail")).length() > 1)
commandDetail += " (" + conn.get("commandDetail") + ")"; commandDetail += " (" + conn.get("commandDetail") + ")";


row.fields("ID", conn.get("connectionId"), "REMOTE_ADDRESS", conn.get("remoteAddress"), "CONNECTED_ON", row.fields("ID", conn.get("connectionId"), "REMOTE_ADDRESS", conn.get("remoteAddress"), "LAST_OPERATION_ON",
conn.get("connectedOn"), "DATABASE", conn.get("db"), "USER", conn.get("user"), "COMMAND", commandDetail, "TOT_REQS", conn.get("lastCommandOn"), "DATABASE", conn.get("db"), "USER", conn.get("user"), "COMMAND", commandDetail, "TOT_REQS",
conn.get("totalRequests")); conn.get("totalRequests"));
resultSet.add(row); resultSet.add(row);
} }


resultSet.sort(new Comparator<OIdentifiable>() {
@Override
public int compare(final OIdentifiable o1,final OIdentifiable o2) {
final String o1s = ((ODocument) o1).field("LAST_OPERATION_ON");
final String o2s = ((ODocument) o2).field("LAST_OPERATION_ON");
return o2s.compareTo(o1s);
}
});

final OTableFormatter formatter = new OTableFormatter(this); final OTableFormatter formatter = new OTableFormatter(this);
formatter.writeRecords(resultSet, -1); formatter.writeRecords(resultSet, -1);


Expand Down
Expand Up @@ -347,6 +347,8 @@ public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2)


if (tempRids) if (tempRids)
columns.remove("@RID"); columns.remove("@RID");
if (!hasClass)
columns.remove("@CLASS");


return columns; return columns;
} }
Expand Down

0 comments on commit 9596bcf

Please sign in to comment.