Skip to content

Commit ede7bcf

Browse files
dmarkhasezraroi
authored andcommitted
get tags from configmanager if node discovery strategy is configuration (#250)
* get tags from configmanager if node discovery strategy is configuration * get tags from configmanager if node discovery strategy is configuration
1 parent 9689d6d commit ede7bcf

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/peer/codeine/servlets/CommandNodeServlet.java

+19-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import codeine.jsons.command.CommandParameterInfo;
1111
import codeine.jsons.global.ExperimentalConfJsonStore;
1212
import codeine.jsons.global.GlobalConfigurationJsonStore;
13+
import codeine.jsons.nodes.NodeDiscoveryStrategy;
1314
import codeine.jsons.peer_status.PeerStatus;
1415
import codeine.jsons.project.ProjectJson;
1516
import codeine.model.Constants;
@@ -26,6 +27,7 @@
2627
import com.google.common.collect.Maps;
2728
import java.io.File;
2829
import java.io.PrintWriter;
30+
import java.util.ArrayList;
2931
import java.util.List;
3032
import java.util.Map;
3133
import java.util.UUID;
@@ -151,9 +153,8 @@ private void executeInternal(HttpServletRequest request, HttpServletResponse res
151153
env.put(Constants.EXECUTION_ENV_PROJECT_NAME, commandInfo.project_name());
152154
env.put(Constants.EXECUTION_ENV_NODE_NAME, commandInfo2.node_name());
153155
env.put(Constants.EXECUTION_ENV_NODE_ALIAS, commandInfo2.node_alias());
154-
env.put(Constants.EXECUTION_ENV_NODE_TAGS, StringUtils.collectionToString(
155-
projectStatusUpdater.getTags(commandInfo.project_name(), commandInfo2.node_name()),
156-
";"));
156+
env.put(Constants.EXECUTION_ENV_NODE_TAGS,
157+
StringUtils.collectionToString(getTags(commandInfo.project_name(), commandInfo2.node_name()),";"));
157158
env.put(Constants.EXECUTION_ENV_CODEINE_SERVER,
158159
globalConfigurationJsonStore.get().web_server_host());
159160
env.put(Constants.EXECUTION_ENV_CODEINE_SERVER_PORT,
@@ -211,6 +212,21 @@ private Map<String, String> getEnvParams(CommandInfo commandJson) {
211212
return $;
212213
}
213214

215+
private List<String> getTags(String projectName, String nodeName) {
216+
List<String> tags = new ArrayList<>();
217+
ProjectJson projectJson = configurationManager.getProjectForName(projectName);
218+
if (projectJson.node_discovery_startegy().equals(NodeDiscoveryStrategy.Configuration)) {
219+
projectJson.nodes_info().stream()
220+
.filter(n -> n.name().equals(nodeName))
221+
.findFirst()
222+
.ifPresent(n -> tags.addAll(n.tags()));
223+
}
224+
else {
225+
tags.addAll(projectStatusUpdater.getTags(projectName, nodeName));
226+
}
227+
return tags;
228+
}
229+
214230
private String encodeIfNeeded(String text, String cred) {
215231
return null == cred ? text : CredHelper.encode(text);
216232
}

0 commit comments

Comments
 (0)