use of org.eclipse.che.api.agent.server.exception.AgentException in project che by eclipse.
the class CheEnvironmentEngine method addAgentsProvidedServers.
private void addAgentsProvidedServers(MachineImpl machine, List<String> agentKeys) throws ServerException {
for (String agentKey : agentKeys) {
try {
AgentImpl agent = new AgentImpl(agentRegistry.getAgent(AgentKeyImpl.parse(agentKey)));
for (Map.Entry<String, ? extends ServerConf2> entry : agent.getServers().entrySet()) {
String ref = entry.getKey();
ServerConf2 conf2 = entry.getValue();
ServerConfImpl conf = new ServerConfImpl(ref, conf2.getPort(), conf2.getProtocol(), conf2.getProperties().get("path"));
machine.getConfig().getServers().add(conf);
}
} catch (AgentException e) {
throw new ServerException(e);
}
}
}
use of org.eclipse.che.api.agent.server.exception.AgentException in project che by eclipse.
the class WorkspaceRuntimes method launchAgents.
protected void launchAgents(Instance instance, List<String> agents) throws ServerException {
try {
for (AgentKey agentKey : agentSorter.sort(agents)) {
if (!Thread.currentThread().isInterrupted()) {
LOG.info("Launching '{}' agent at workspace {}", agentKey.getId(), instance.getWorkspaceId());
Agent agent = agentRegistry.getAgent(agentKey);
AgentLauncher launcher = launcherFactory.find(agentKey.getId(), instance.getConfig().getType());
launcher.launch(instance, agent);
}
}
} catch (AgentException e) {
throw new MachineException(e.getMessage(), e);
}
}
use of org.eclipse.che.api.agent.server.exception.AgentException in project che by eclipse.
the class AgentSorter method doSort.
private void doSort(AgentKey agentKey, List<AgentKey> sorted, Set<String> pending) throws AgentException {
String agentId = agentKey.getId();
Optional<AgentKey> alreadySorted = sorted.stream().filter(k -> k.getId().equals(agentId)).findFirst();
if (alreadySorted.isPresent()) {
return;
}
pending.add(agentId);
Agent agent = agentRegistry.getAgent(agentKey);
for (String dependency : agent.getDependencies()) {
if (pending.contains(dependency)) {
throw new AgentException(String.format("Agents circular dependency found between '%s' and '%s'", dependency, agentId));
}
doSort(AgentKeyImpl.parse(dependency), sorted, pending);
}
sorted.add(agentKey);
pending.remove(agentId);
}
Aggregations