Skip to content

Commit 233832d

Browse files
committed
2 parents 871caca + 0a2efa0 commit 233832d

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

src/web_server/codeine/command_peer/NodesCommandExecuterProvider.java

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ public List<CommandStatusJson> getAllCommands(String projectName, String nodeNam
5757
String file = parentDir + "/" + dir + Constants.JSON_COMMAND_FILE_NAME;
5858
try {
5959
CommandExecutionStatusInfo j = gson.fromJson(TextFileUtils.getContents(file), CommandExecutionStatusInfo.class);
60+
if (!shouldShowByNode(j, nodeName)){
61+
continue;
62+
}
6063
int size = j.nodes_list().size();
6164
int successSize = j.success_list().size();
6265
int failSize = j.fail_list().size();
@@ -78,6 +81,23 @@ public int compare(CommandStatusJson o1, CommandStatusJson o2) {
7881
return $;
7982
}
8083

84+
private boolean shouldShowByNode(CommandExecutionStatusInfo j, String nodeName) {
85+
List<NodeWithPeerInfo> nodes_list = j.nodes_list();
86+
return shouldShowByNode(nodeName, nodes_list);
87+
}
88+
89+
private boolean shouldShowByNode(String nodeName, List<NodeWithPeerInfo> nodes_list) {
90+
if (nodeName == null) {
91+
return true;
92+
}
93+
for (NodeWithPeerInfo node : nodes_list) {
94+
if (node.name().equals(nodeName)) {
95+
return true;
96+
}
97+
}
98+
return false;
99+
}
100+
81101
private boolean contains(List<CommandStatusJson> $, String dir) {
82102
for (CommandStatusJson commandStatusJson : $) {
83103
if (String.valueOf(commandStatusJson.id()).equals(dir)){
@@ -98,15 +118,8 @@ public boolean apply(AllNodesCommandExecuter c){
98118
return getActive(filter);
99119
}
100120
private boolean shouldShowByNode(AllNodesCommandExecuter c, String nodeName) {
101-
if (nodeName == null) {
102-
return true;
103-
}
104-
for (NodeWithPeerInfo node : c.nodesList()) {
105-
if (node.name().equals(nodeName)) {
106-
return true;
107-
}
108-
}
109-
return false;
121+
List<NodeWithPeerInfo> nodes_list = c.nodesList();
122+
return shouldShowByNode(nodeName, nodes_list);
110123
}
111124

112125
public List<CommandStatusJson> getActive(Predicate<AllNodesCommandExecuter> filter) {

0 commit comments

Comments
 (0)