use of org.eclipse.che.api.agent.shared.model.impl.AgentImpl 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.shared.model.impl.AgentImpl in project che by eclipse.
the class ExecAgentLauncher method launch.
@Override
public void launch(Instance machine, Agent agent) throws ServerException {
final AgentImpl agentCopy = new AgentImpl(agent);
agentCopy.setScript(agent.getScript() + "\n" + runCommand);
super.launch(machine, agentCopy);
}
use of org.eclipse.che.api.agent.shared.model.impl.AgentImpl in project che by eclipse.
the class SshMachineExecAgentLauncher method launch.
public void launch(SshMachineInstance machine, Agent agent) throws ServerException {
if (isNullOrEmpty(agent.getScript())) {
return;
}
try {
String architecture = detectArchitecture(machine);
machine.copy(archivePathProvider.getPath(architecture), terminalLocation);
final AgentImpl agentCopy = new AgentImpl(agent);
agentCopy.setScript(agent.getScript() + "\n" + terminalRunCommand);
final SshMachineProcess process = start(machine, agentCopy);
LOG.debug("Waiting for agent {} is launched. Workspace ID:{}", agentCopy.getId(), machine.getWorkspaceId());
final long pingStartTimestamp = System.currentTimeMillis();
SshProcessLaunchedChecker agentLaunchingChecker = new SshProcessLaunchedChecker("che-websocket-terminal");
while (System.currentTimeMillis() - pingStartTimestamp < agentMaxStartTimeMs) {
if (agentLaunchingChecker.isLaunched(agentCopy, machine)) {
return;
} else {
Thread.sleep(agentPingDelayMs);
}
}
process.kill();
final String errMsg = format("Fail launching agent %s. Workspace ID:%s", agent.getName(), machine.getWorkspaceId());
LOG.error(errMsg);
throw new ServerException(errMsg);
} catch (MachineException e) {
throw new ServerException(e.getServiceError());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ServerException(format("Launching agent %s is interrupted", agent.getName()));
} catch (ConflictException e) {
// should never happen
throw new ServerException("Internal server error occurs on terminal launching.");
}
}
Aggregations