use of org.eclipse.che.api.agent.shared.model.AgentKey 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.shared.model.AgentKey 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);
}
use of org.eclipse.che.api.agent.shared.model.AgentKey in project che by eclipse.
the class AgentConfigApplier method apply.
/**
* Applies docker specific properties to a machine.
*
* @param machineConf
* machine config with the list of agents that should be injected into machine
* @param machine
* affected machine
* @throws AgentException
* if any error occurs
*/
public void apply(@Nullable ExtendedMachine machineConf, CheServiceImpl machine) throws AgentException {
if (machineConf != null) {
for (AgentKey agentKey : sorter.sort(machineConf.getAgents())) {
Agent agent = agentRegistry.getAgent(agentKey);
addEnv(machine, agent.getProperties());
addExposedPorts(machine, agent.getServers());
addLabels(machine, agent.getServers());
}
}
}
Aggregations