CHE-3720: Decouple different agents on different maven modules (#3830)
parent
47755be36e
commit
c8dafb9c6b
|
|
@ -39,5 +39,9 @@
|
|||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-commons-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-commons-lang</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent.shared.model;
|
||||
|
||||
import org.eclipse.che.commons.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A pair of id and version of the agent.
|
||||
* Version part is not mandatory.
|
||||
|
|
@ -27,6 +25,5 @@ public interface AgentKey {
|
|||
/**
|
||||
* @return the version of the agent
|
||||
*/
|
||||
@Nullable
|
||||
String getVersion();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent.server.model.impl;
|
||||
package org.eclipse.che.api.agent.shared.model.impl;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.core.model.workspace.ServerConf2;
|
||||
|
|
@ -8,8 +8,9 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent.server.model.impl;
|
||||
package org.eclipse.che.api.agent.shared.model.impl;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.agent.shared.model.AgentKey;
|
||||
import org.eclipse.che.commons.annotation.Nullable;
|
||||
|
||||
|
|
@ -19,16 +20,21 @@ import java.util.Objects;
|
|||
* @author Anatolii Bazko
|
||||
*/
|
||||
public class AgentKeyImpl implements AgentKey {
|
||||
private static final String DEFAULT_VERSION = "latest";
|
||||
private final String id;
|
||||
private final String version;
|
||||
|
||||
public AgentKeyImpl(String id, @Nullable String version) {
|
||||
this.id = id;
|
||||
this.version = version;
|
||||
this.version = version == null ? DEFAULT_VERSION : version;
|
||||
}
|
||||
|
||||
public AgentKeyImpl(String name) {
|
||||
this(name, null);
|
||||
public AgentKeyImpl(String id) {
|
||||
this(id, null);
|
||||
}
|
||||
|
||||
public AgentKeyImpl(Agent agent) {
|
||||
this(agent.getId(), agent.getVersion());
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
|
@ -50,7 +56,7 @@ public class AgentKeyImpl implements AgentKey {
|
|||
String[] parts = agentKey.split(":");
|
||||
|
||||
if (parts.length == 1) {
|
||||
return new AgentKeyImpl(parts[0], null);
|
||||
return new AgentKeyImpl(parts[0]);
|
||||
} else if (parts.length == 2) {
|
||||
return new AgentKeyImpl(parts[0], parts[1]);
|
||||
} else {
|
||||
|
|
@ -79,7 +85,7 @@ public class AgentKeyImpl implements AgentKey {
|
|||
@Override
|
||||
public String toString() {
|
||||
return "AgentImpl{" +
|
||||
"name='" + id + '\'' +
|
||||
"id='" + id + '\'' +
|
||||
", version='" + version + "\'}";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent.shared.model.impl;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.dto.AgentDto;
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.core.model.workspace.ServerConf2;
|
||||
import org.eclipse.che.commons.lang.IoUtil;
|
||||
import org.eclipse.che.dto.server.DtoFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.lang.String.format;
|
||||
import static java.util.Collections.unmodifiableList;
|
||||
import static java.util.Collections.unmodifiableMap;
|
||||
|
||||
/**
|
||||
* Basic implementation of the {@link Agent}.
|
||||
*
|
||||
* It is supposed that agent descriptor and agent script are located
|
||||
* as resources in the jar.
|
||||
*
|
||||
* If resources aren't found then {@link Agent} won't be initialized.
|
||||
*
|
||||
* @author Anatolii Bazko
|
||||
*/
|
||||
public abstract class BasicAgent implements Agent {
|
||||
private final Agent internal;
|
||||
|
||||
public BasicAgent(String agentDescriptor, String agentScript) throws IOException {
|
||||
internal = readAgentDescriptor(agentDescriptor, agentScript);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return internal.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return internal.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return internal.getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return internal.getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDependencies() {
|
||||
return unmodifiableList(internal.getDependencies());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getScript() {
|
||||
return internal.getScript();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getProperties() {
|
||||
return unmodifiableMap(internal.getProperties());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ? extends ServerConf2> getServers() {
|
||||
return unmodifiableMap(internal.getServers());
|
||||
}
|
||||
|
||||
private Agent readAgentDescriptor(String agentDescriptor, String agentScript) throws IOException {
|
||||
InputStream inputStream = readResource(agentDescriptor);
|
||||
AgentDto agent = DtoFactory.getInstance().createDtoFromJson(inputStream, AgentDto.class);
|
||||
return agent.withScript(readAgentScript(agentScript));
|
||||
}
|
||||
|
||||
private String readAgentScript(String agentScript) throws IOException {
|
||||
InputStream inputStream = readResource(agentScript);
|
||||
return IoUtil.readStream(inputStream);
|
||||
}
|
||||
|
||||
private InputStream readResource(String resource) throws IOException {
|
||||
InputStream inputStream = getClass().getResourceAsStream("/" + resource);
|
||||
if (inputStream == null) {
|
||||
throw new IOException(format("Can't initialize agent. Resource %s not found", resource));
|
||||
}
|
||||
return inputStream;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -39,18 +39,10 @@
|
|||
<groupId>com.google.inject</groupId>
|
||||
<artifactId>guice</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.inject.extensions</groupId>
|
||||
<artifactId>guice-multibindings</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>javax.ws.rs-api</artifactId>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import com.google.inject.Inject;
|
|||
|
||||
import org.eclipse.che.api.agent.server.exception.AgentException;
|
||||
import org.eclipse.che.api.agent.server.exception.AgentNotFoundException;
|
||||
import org.eclipse.che.api.agent.server.model.impl.AgentKeyImpl;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.AgentKeyImpl;
|
||||
import org.eclipse.che.api.agent.shared.dto.AgentDto;
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.core.ApiException;
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent.server;
|
||||
|
||||
import org.eclipse.che.api.agent.server.exception.AgentException;
|
||||
import org.eclipse.che.api.agent.shared.model.AgentKey;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* @author Anatolii Bazko
|
||||
*/
|
||||
public interface AgentRegistryUrlProvider {
|
||||
/**
|
||||
* Returns url to download agent of the specific version.
|
||||
*
|
||||
* @param agentKey
|
||||
* the agent name and version
|
||||
* @return {@link URL}
|
||||
* @throws AgentException
|
||||
* if unexpected error occurred
|
||||
*/
|
||||
URL getAgentUrl(AgentKey agentKey) throws AgentException;
|
||||
|
||||
/**
|
||||
* Returns url to fetch available versions of the agent.
|
||||
|
||||
* @param name
|
||||
* the agent id
|
||||
* @return {@link URL}
|
||||
* @throws AgentException
|
||||
* if unexpected error occurred
|
||||
*/
|
||||
URL getAgentVersionsUrl(String id) throws AgentException;
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent.server.impl;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.che.api.agent.server.AgentRegistry;
|
||||
import org.eclipse.che.api.agent.server.exception.AgentException;
|
||||
import org.eclipse.che.api.agent.server.exception.AgentNotFoundException;
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.agent.shared.model.AgentKey;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.AgentKeyImpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.lang.String.format;
|
||||
import static java.util.Collections.unmodifiableCollection;
|
||||
|
||||
/**
|
||||
* Local implementation of the {@link AgentRegistry}.
|
||||
* The name of the agent might represent a url.
|
||||
*
|
||||
* @author Anatoliy Bazko
|
||||
*/
|
||||
@Singleton
|
||||
public class AgentRegistryImpl implements AgentRegistry {
|
||||
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(AgentRegistryImpl.class);
|
||||
|
||||
private final Map<AgentKey, Agent> agents;
|
||||
|
||||
/**
|
||||
* AgentRegistryImpl constructor.
|
||||
*
|
||||
* @param agents
|
||||
* list of agents to register
|
||||
* @throws IllegalArgumentException
|
||||
* if there are several agents with same id and version
|
||||
*/
|
||||
@Inject
|
||||
public AgentRegistryImpl(Set<Agent> agents) throws IllegalArgumentException {
|
||||
this.agents = new HashMap<>(agents.size());
|
||||
for (Agent agent : agents) {
|
||||
AgentKeyImpl key = new AgentKeyImpl(agent);
|
||||
Agent registeredAgent = this.agents.put(key, agent);
|
||||
if (registeredAgent != null) {
|
||||
throw new IllegalArgumentException(format("Agent with key %s has been registered already.", key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Agent getAgent(AgentKey agentKey) throws AgentException {
|
||||
return doGetAgent(agentKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVersions(String id) throws AgentException {
|
||||
return agents.entrySet().stream()
|
||||
.filter(e -> e.getKey().getId().equals(id))
|
||||
.map(e -> e.getKey().getVersion())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Agent> getAgents() throws AgentException {
|
||||
return unmodifiableCollection(agents.values());
|
||||
}
|
||||
|
||||
private Agent doGetAgent(AgentKey key) throws AgentException {
|
||||
Optional<Agent> agent = Optional.ofNullable(agents.get(key));
|
||||
return agent.orElseThrow(() -> new AgentNotFoundException(format("Agent %s not found", key.getId())));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent.server.impl;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.che.api.agent.server.AgentRegistryUrlProvider;
|
||||
import org.eclipse.che.api.agent.server.exception.AgentException;
|
||||
import org.eclipse.che.api.agent.shared.model.AgentKey;
|
||||
|
||||
import javax.inject.Named;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Provides urls to agents.
|
||||
*
|
||||
* @author Anatolii Bazko
|
||||
*/
|
||||
@Singleton
|
||||
public class AgentRegistryUrlProviderImpl implements AgentRegistryUrlProvider {
|
||||
public static final String VERSION = "${version}";
|
||||
public static final String ID = "${id}";
|
||||
|
||||
private final String agentLatestVersionUrl;
|
||||
private final String agentSpecificVersionUrl;
|
||||
private final String agentVersionsUrl;
|
||||
|
||||
@Inject
|
||||
public AgentRegistryUrlProviderImpl(@Named("machine.agent.latest_version_url") String agentLatestVersionUrl,
|
||||
@Named("machine.agent.specific_version_url") String agentSpecificVersionUrl,
|
||||
@Named("machine.agent.all_versions_url") String agentVersionsUrl) {
|
||||
this.agentLatestVersionUrl = agentLatestVersionUrl;
|
||||
this.agentSpecificVersionUrl = agentSpecificVersionUrl;
|
||||
this.agentVersionsUrl = agentVersionsUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getAgentUrl(AgentKey agentKey) throws AgentException {
|
||||
String url;
|
||||
if (agentKey.getVersion() == null) {
|
||||
url = agentLatestVersionUrl.replace(ID, agentKey.getId());
|
||||
} else {
|
||||
url = agentSpecificVersionUrl.replace(ID, agentKey.getId()).replace(VERSION, agentKey.getVersion());
|
||||
}
|
||||
try {
|
||||
return new URL(url);
|
||||
} catch (MalformedURLException e) {
|
||||
throw new AgentException("Malformed url " + url, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public URL getAgentVersionsUrl(String id) throws AgentException {
|
||||
String url = agentVersionsUrl.replace(ID, id);
|
||||
try {
|
||||
return new URL(url);
|
||||
} catch (MalformedURLException e) {
|
||||
throw new AgentException("Malformed url " + url, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ import com.google.inject.Singleton;
|
|||
|
||||
import org.eclipse.che.api.agent.server.AgentRegistry;
|
||||
import org.eclipse.che.api.agent.server.exception.AgentException;
|
||||
import org.eclipse.che.api.agent.server.model.impl.AgentKeyImpl;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.AgentKeyImpl;
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.agent.shared.model.AgentKey;
|
||||
import org.eclipse.che.commons.annotation.Nullable;
|
||||
|
|
|
|||
|
|
@ -1,158 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent.server.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.che.api.agent.server.AgentRegistry;
|
||||
import org.eclipse.che.api.agent.server.exception.AgentException;
|
||||
import org.eclipse.che.api.agent.server.exception.AgentNotFoundException;
|
||||
import org.eclipse.che.api.agent.shared.dto.AgentDto;
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.agent.shared.model.AgentKey;
|
||||
import org.eclipse.che.api.core.util.FileCleaner;
|
||||
import org.eclipse.che.commons.lang.ZipUtils;
|
||||
import org.eclipse.che.dto.server.DtoFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import static java.lang.String.format;
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.eclipse.che.commons.lang.IoUtil.downloadFile;
|
||||
import static org.eclipse.che.commons.lang.IoUtil.readAndCloseQuietly;
|
||||
import static org.eclipse.che.commons.lang.ZipUtils.isZipFile;
|
||||
|
||||
/**
|
||||
* Local implementation of the {@link AgentRegistry}.
|
||||
* The name of the agent might represent a url.
|
||||
*
|
||||
* @author Anatoliy Bazko
|
||||
*/
|
||||
@Singleton
|
||||
public class LocalAgentRegistryImpl implements AgentRegistry {
|
||||
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(LocalAgentRegistryImpl.class);
|
||||
private static final Pattern AGENTS = Pattern.compile(".*[//]?agents/[^//]+[.]json");
|
||||
|
||||
private final Map<String, Agent> agents;
|
||||
private final List<String> agentIds;
|
||||
|
||||
@Inject
|
||||
public LocalAgentRegistryImpl(Set<Agent> agents) throws IOException {
|
||||
|
||||
this.agents = new HashMap<>();
|
||||
findAgents();
|
||||
for (Agent agent : agents) {
|
||||
this.agents.put(agent.getId(), agent);
|
||||
}
|
||||
this.agentIds = ImmutableList.copyOf(this.agents.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Agent getAgent(AgentKey agentKey) throws AgentException {
|
||||
return doGetAgent(agentKey.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVersions(String id) throws AgentException {
|
||||
Agent agent = doGetAgent(id);
|
||||
String version = agent.getVersion();
|
||||
return version == null ? Collections.emptyList() : singletonList(version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Agent> getAgents() throws AgentException {
|
||||
return agents.values();
|
||||
}
|
||||
|
||||
protected Agent doGetAgent(String id) throws AgentException {
|
||||
try {
|
||||
URL url = new URL(id);
|
||||
return doGetRemoteAgent(url);
|
||||
} catch (MalformedURLException ignored) {
|
||||
// id doesn't represent a url
|
||||
}
|
||||
|
||||
Optional<Agent> agent = Optional.ofNullable(agents.get(id));
|
||||
return agent.orElseThrow(() -> new AgentNotFoundException(format("Agent %s not found", id)));
|
||||
}
|
||||
|
||||
protected Agent doGetRemoteAgent(URL url) throws AgentException {
|
||||
File agent = null;
|
||||
try {
|
||||
agent = downloadFile(new File(System.getProperty("java.io.tmpdir")), "agent", ".tmp", url);
|
||||
String json = readAndCloseQuietly(new FileInputStream(agent));
|
||||
return DtoFactory.getInstance().createDtoFromJson(json, AgentDto.class);
|
||||
} catch (IOException | IllegalArgumentException e) {
|
||||
throw new AgentException("Can't fetch agent configuration", e);
|
||||
} finally {
|
||||
if (agent != null) {
|
||||
try {
|
||||
Files.delete(agent.toPath());
|
||||
} catch (IOException e) {
|
||||
FileCleaner.addFile(agent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void findAgents() throws IOException {
|
||||
File context = new File(LocalAgentRegistryImpl.class.getProtectionDomain().getCodeSource().getLocation().getPath());
|
||||
|
||||
if (isZipFile(context)) {
|
||||
try (ZipFile zip = new ZipFile(context)) {
|
||||
ZipUtils.getResources(zip, AGENTS, createAgentsConsumer);
|
||||
}
|
||||
} else {
|
||||
Files.walk(context.toPath())
|
||||
.filter(path -> AGENTS.matcher(path.toString()).matches())
|
||||
.forEach(path -> {
|
||||
try (InputStream in = Files.newInputStream(path)) {
|
||||
createAgentsConsumer.accept(in);
|
||||
} catch (IOException ignored) {
|
||||
// ignore
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private Consumer<InputStream> createAgentsConsumer = new Consumer<InputStream>() {
|
||||
@Override
|
||||
public void accept(InputStream inputStream) {
|
||||
try {
|
||||
final Agent agent = DtoFactory.getInstance().createDtoFromJson(inputStream, AgentDto.class);
|
||||
agents.put(agent.getId(), agent);
|
||||
} catch (IOException e) {
|
||||
LOG.error("Can't create agent.", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"id": "org.eclipse.che.ls.json",
|
||||
"name": "JSON language server",
|
||||
"description" : "JSON intellisense",
|
||||
"dependencies": [],
|
||||
"properties": {
|
||||
},
|
||||
"script" : "#\n# Copyright (c) 2012-2017 Codenvy, S.A.\n# All rights reserved. This program and the accompanying materials\n# are made available under the terms of the Eclipse Public License v1.0\n# which accompanies this distribution, and is available at\n# http://www.eclipse.org/legal/epl-v10.html\n#\n# Contributors:\n# Codenvy, S.A. - initial API and implementation\n#\n\nunset PACKAGES\nunset SUDO\ncommand -v tar >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" tar\"; }\ncommand -v curl >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" curl\"; }\ntest \"$(id -u)\" = 0 || SUDO=\"sudo\"\n\nAGENT_BINARIES_URI=https://codenvy.com/update/repository/public/download/org.eclipse.che.ls.json.binaries\nCHE_DIR=$HOME/che\nLS_DIR=${CHE_DIR}/ls-json\nLS_LAUNCHER=${LS_DIR}/launch.sh\n\nif [ -f /etc/centos-release ]; then\n FILE=\"/etc/centos-release\"\n LINUX_TYPE=$(cat $FILE | awk '{print $1}')\n elif [ -f /etc/redhat-release ]; then\n FILE=\"/etc/redhat-release\"\n LINUX_TYPE=$(cat $FILE | cut -c 1-8)\n else\n FILE=\"/etc/os-release\"\n LINUX_TYPE=$(cat $FILE | grep ^ID= | tr '[:upper:]' '[:lower:]')\n LINUX_VERSION=$(cat $FILE | grep ^VERSION_ID=)\nfi\n\nMACHINE_TYPE=$(uname -m)\n\nmkdir -p ${CHE_DIR}\nmkdir -p ${LS_DIR}\n\n########################\n### Install packages ###\n########################\n\n# Red Hat Enterprise Linux 7\n############################\nif echo ${LINUX_TYPE} | grep -qi \"rhel\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} yum install ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -;\n ${SUDO} yum -y install nodejs;\n }\n\n# Red Hat Enterprise Linux 6\n############################\nelif echo ${LINUX_TYPE} | grep -qi \"Red Hat\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} yum install ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -;\n ${SUDO} yum -y install nodejs;\n }\n\n\n# Ubuntu 14.04 16.04 / Linux Mint 17\n####################################\nelif echo ${LINUX_TYPE} | grep -qi \"ubuntu\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} apt-get update;\n ${SUDO} apt-get -y install ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n {\n if test \"${SUDO}\" = \"\"; then\n curl -sL https://deb.nodesource.com/setup_6.x | bash -;\n else\n curl -sL https://deb.nodesource.com/setup_6.x | ${SUDO} -E bash -;\n fi\n };\n\n ${SUDO} apt-get update;\n ${SUDO} apt-get install -y nodejs;\n }\n\n\n# Debian 8\n##########\nelif echo ${LINUX_TYPE} | grep -qi \"debian\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} apt-get update;\n ${SUDO} apt-get -y install ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n {\n if test \"${SUDO}\" = \"\"; then\n curl -sL https://deb.nodesource.com/setup_6.x | bash -;\n else\n curl -sL https://deb.nodesource.com/setup_6.x | ${SUDO} -E bash -;\n fi\n };\n\n ${SUDO} apt-get update;\n ${SUDO} apt-get install -y nodejs;\n }\n\n# Fedora 23\n###########\nelif echo ${LINUX_TYPE} | grep -qi \"fedora\"; then\n command -v ps >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" procps-ng\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} dnf -y install ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -;\n ${SUDO} dnf -y install nodejs;\n }\n\n\n# CentOS 7.1 & Oracle Linux 7.1\n###############################\nelif echo ${LINUX_TYPE} | grep -qi \"centos\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} yum -y install ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -;\n ${SUDO} yum -y install nodejs;\n }\n\n# openSUSE 13.2\n###############\nelif echo ${LINUX_TYPE} | grep -qi \"opensuse\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} zypper install -y ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n ${SUDO} zypper ar http://download.opensuse.org/repositories/devel:/languages:/nodejs/openSUSE_13.1/ Node.js\n ${SUDO} zypper in nodejs\n }\n\nelse\n >&2 echo \"Unrecognized Linux Type\"\n >&2 cat $FILE\n exit 1\nfi\n\n\n#####################\n### Install C# LS ###\n#####################\n\ncurl -s ${AGENT_BINARIES_URI} | tar xzf - -C ${LS_DIR}\n\ntouch ${LS_LAUNCHER}\nchmod +x ${LS_LAUNCHER}\necho \"nodejs ${LS_DIR}/vscode-json-server/server.js\" > ${LS_LAUNCHER}"
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"id": "org.eclipse.che.ls.php",
|
||||
"name": "PHP language server",
|
||||
"description": "PHP intellisense",
|
||||
"dependencies": [],
|
||||
"properties": {},
|
||||
"script" : "#\n# Copyright (c) 2012-2017 Codenvy, S.A.\n# All rights reserved. This program and the accompanying materials\n# are made available under the terms of the Eclipse Public License v1.0\n# which accompanies this distribution, and is available at\n# http://www.eclipse.org/legal/epl-v10.html\n#\n# Contributors:\n# Codenvy, S.A. - initial API and implementation\n#\n\nunset PACKAGES\nunset SUDO\ncommand -v tar >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" tar\"; }\ncommand -v curl >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" curl\"; }\ntest \"$(id -u)\" = 0 || SUDO=\"sudo\"\n\nAGENT_BINARIES_URI=https://codenvy.com/update/repository/public/download/org.eclipse.che.ls.php.binaries\nCHE_DIR=$HOME/che\nLS_DIR=${CHE_DIR}/ls-php\nLS_LAUNCHER=${LS_DIR}/launch.sh\n\nif [ -f /etc/centos-release ]; then\n FILE=\"/etc/centos-release\"\n LINUX_TYPE=$(cat $FILE | awk '{print $1}')\n elif [ -f /etc/redhat-release ]; then\n FILE=\"/etc/redhat-release\"\n LINUX_TYPE=$(cat $FILE | cut -c 1-8)\n else\n FILE=\"/etc/os-release\"\n LINUX_TYPE=$(cat $FILE | grep ^ID= | tr '[:upper:]' '[:lower:]')\n LINUX_VERSION=$(cat $FILE | grep ^VERSION_ID=)\nfi\n\nMACHINE_TYPE=$(uname -m)\n\nmkdir -p ${CHE_DIR}\nmkdir -p ${LS_DIR}\n\n########################\n### Install packages ###\n########################\n\n# Red Hat Enterprise Linux 7\n############################\nif echo ${LINUX_TYPE} | grep -qi \"rhel\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} yum install ${PACKAGES};\n }\n\n# Red Hat Enterprise Linux 6\n############################\nelif echo ${LINUX_TYPE} | grep -qi \"Red Hat\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} yum install ${PACKAGES};\n }\n\n# Ubuntu 14.04 16.04 / Linux Mint 17\n####################################\nelif echo ${LINUX_TYPE} | grep -qi \"ubuntu\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} apt-get update;\n ${SUDO} apt-get -y install ${PACKAGES};\n }\n\n\n# Debian 8\n##########\nelif echo ${LINUX_TYPE} | grep -qi \"debian\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} apt-get update;\n ${SUDO} apt-get -y install ${PACKAGES};\n }\n\n# Fedora 23\n###########\nelif echo ${LINUX_TYPE} | grep -qi \"fedora\"; then\n command -v ps >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" procps-ng\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} dnf -y install ${PACKAGES};\n }\n\n\n# CentOS 7.1 & Oracle Linux 7.1\n###############################\nelif echo ${LINUX_TYPE} | grep -qi \"centos\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} yum -y install ${PACKAGES};\n }\n\n# openSUSE 13.2\n###############\nelif echo ${LINUX_TYPE} | grep -qi \"opensuse\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} zypper install -y ${PACKAGES};\n }\n\nelse\n >&2 echo \"Unrecognized Linux Type\"\n >&2 cat /etc/os-release\n exit 1\nfi\n\n\n######################\n### Install PHP LS ###\n######################\n\ncurl -s ${AGENT_BINARIES_URI} | tar xzf - -C ${LS_DIR}\n\ntouch ${LS_LAUNCHER}\nchmod +x ${LS_LAUNCHER}\necho \"export LD_LIBRARY_PATH=${LS_DIR}/php7-minimal\" > ${LS_LAUNCHER}\necho \"${LS_DIR}/php7-minimal/php -c ${LS_DIR}/php7-minimal/php.ini ${LS_DIR}/php-language-server/bin/php-language-server.php\" >> ${LS_LAUNCHER}"
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"id": "org.eclipse.che.ls.js-ts",
|
||||
"name": "TypeScript language server",
|
||||
"description" : "TypeScript intellisense",
|
||||
"dependencies": [],
|
||||
"properties": {
|
||||
},
|
||||
"script" : "#\n# Copyright (c) 2012-2017 Codenvy, S.A.\n# All rights reserved. This program and the accompanying materials\n# are made available under the terms of the Eclipse Public License v1.0\n# which accompanies this distribution, and is available at\n# http://www.eclipse.org/legal/epl-v10.html\n#\n# Contributors:\n# Codenvy, S.A. - initial API and implementation\n#\n\nunset PACKAGES\nunset SUDO\ncommand -v tar >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" tar\"; }\ncommand -v curl >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" curl\"; }\ntest \"$(id -u)\" = 0 || SUDO=\"sudo\"\n\nAGENT_BINARIES_URI=https://codenvy.com/update/repository/public/download/org.eclipse.che.ls.typescript.binaries\nCHE_DIR=$HOME/che\nLS_DIR=${CHE_DIR}/ls-typescript\nLS_LAUNCHER=${LS_DIR}/launch.sh\n\nif [ -f /etc/centos-release ]; then\n FILE=\"/etc/centos-release\"\n LINUX_TYPE=$(cat $FILE | awk '{print $1}')\n elif [ -f /etc/redhat-release ]; then\n FILE=\"/etc/redhat-release\"\n LINUX_TYPE=$(cat $FILE | cut -c 1-8)\n else\n FILE=\"/etc/os-release\"\n LINUX_TYPE=$(cat $FILE | grep ^ID= | tr '[:upper:]' '[:lower:]')\n LINUX_VERSION=$(cat $FILE | grep ^VERSION_ID=)\nfi\n\nMACHINE_TYPE=$(uname -m)\n\nmkdir -p ${CHE_DIR}\nmkdir -p ${LS_DIR}\n\n########################\n### Install packages ###\n########################\n\n# Red Hat Enterprise Linux 7\n############################\nif echo ${LINUX_TYPE} | grep -qi \"rhel\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} yum install ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -;\n ${SUDO} yum -y install nodejs;\n }\n\n# Red Hat Enterprise Linux 6\n############################\nelif echo ${LINUX_TYPE} | grep -qi \"Red Hat\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} yum install ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -;\n ${SUDO} yum -y install nodejs;\n }\n\n\n# Ubuntu 14.04 16.04 / Linux Mint 17\n####################################\nelif echo ${LINUX_TYPE} | grep -qi \"ubuntu\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} apt-get update;\n ${SUDO} apt-get -y install ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n {\n if test \"${SUDO}\" = \"\"; then\n curl -sL https://deb.nodesource.com/setup_6.x | bash -;\n else\n curl -sL https://deb.nodesource.com/setup_6.x | ${SUDO} -E bash -;\n fi\n };\n\n ${SUDO} apt-get update;\n ${SUDO} apt-get install -y nodejs;\n }\n\n\n# Debian 8\n##########\nelif echo ${LINUX_TYPE} | grep -qi \"debian\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} apt-get update;\n ${SUDO} apt-get -y install ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n {\n if test \"${SUDO}\" = \"\"; then\n curl -sL https://deb.nodesource.com/setup_6.x | bash -;\n else\n curl -sL https://deb.nodesource.com/setup_6.x | ${SUDO} -E bash -;\n fi\n };\n\n ${SUDO} apt-get update;\n ${SUDO} apt-get install -y nodejs;\n }\n\n# Fedora 23\n###########\nelif echo ${LINUX_TYPE} | grep -qi \"fedora\"; then\n command -v ps >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" procps-ng\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} dnf -y install ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -;\n ${SUDO} dnf -y install nodejs;\n }\n\n\n# CentOS 7.1 & Oracle Linux 7.1\n###############################\nelif echo ${LINUX_TYPE} | grep -qi \"centos\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} yum -y install ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n curl --silent --location https://rpm.nodesource.com/setup_6.x | ${SUDO} bash -;\n ${SUDO} yum -y install nodejs;\n }\n\n# openSUSE 13.2\n###############\nelif echo ${LINUX_TYPE} | grep -qi \"opensuse\"; then\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} zypper install -y ${PACKAGES};\n }\n\n command -v nodejs >/dev/null 2>&1 || {\n ${SUDO} zypper ar http://download.opensuse.org/repositories/devel:/languages:/nodejs/openSUSE_13.1/ Node.js\n ${SUDO} zypper in nodejs\n }\n\nelse\n >&2 echo \"Unrecognized Linux Type\"\n >&2 cat $FILE\n exit 1\nfi\n\n\n########################\n### Install JS-TS LS ###\n########################\n\ncurl -s ${AGENT_BINARIES_URI} | tar xzf - -C ${LS_DIR}\n\ntouch ${LS_LAUNCHER}\nchmod +x ${LS_LAUNCHER}\necho \"nodejs ${LS_DIR}/build/language-server-stdio.js\" > ${LS_LAUNCHER}"
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"id": "org.eclipse.che.ssh",
|
||||
"name": "SSH",
|
||||
"description": "SSH server, key-pair generation",
|
||||
"dependencies": [],
|
||||
"properties": {},
|
||||
"servers": {
|
||||
"ssh": {
|
||||
"port": "22/tcp"
|
||||
}
|
||||
},
|
||||
"script" : "#\n# Copyright (c) 2012-2017 Codenvy, S.A.\n# All rights reserved. This program and the accompanying materials\n# are made available under the terms of the Eclipse Public License v1.0\n# which accompanies this distribution, and is available at\n# http://www.eclipse.org/legal/epl-v10.html\n#\n# Contributors:\n# Codenvy, S.A. - initial API and implementation\n#\n\nunset SUDO\nunset PACKAGES\ntest \"$(id -u)\" = 0 || SUDO=\"sudo\"\n\nif [ -f /etc/centos-release ]; then\n FILE=\"/etc/centos-release\"\n LINUX_TYPE=$(cat $FILE | awk '{print $1}')\n elif [ -f /etc/redhat-release ]; then\n FILE=\"/etc/redhat-release\"\n LINUX_TYPE=$(cat $FILE | cut -c 1-8)\n else\n FILE=\"/etc/os-release\"\n LINUX_TYPE=$(cat $FILE | grep ^ID= | tr '[:upper:]' '[:lower:]')\n LINUX_VERSION=$(cat $FILE | grep ^VERSION_ID=)\nfi\n\n###############################\n### Install Needed packaged ###\n###############################\n\n# Red Hat Enterprise Linux 7 \n############################\nif echo ${LINUX_TYPE} | grep -qi \"rhel\"; then\n command -v sshd >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" openssh-server\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} yum -y install ${PACKAGES};\n }\n ${SUDO} sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd\n\n# Red Hat Enterprise Linux 6 \n############################\nelif echo ${LINUX_TYPE} | grep -qi \"Red Hat\"; then\n command -v sshd >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" openssh-server\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} yum -y install ${PACKAGES};\n }\n ${SUDO} sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd\n\n# Ubuntu 14.04 16.04 / Linux Mint 17 \n####################################\nelif echo ${LINUX_TYPE} | grep -qi \"ubuntu\"; then\n command -v sshd >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" openssh-server\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} apt-get update;\n ${SUDO} apt-get -y install ${PACKAGES};\n }\n ${SUDO} sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd\n\n# Debian 8\n##########\nelif echo ${LINUX_TYPE} | grep -qi \"debian\"; then\n command -v sshd >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" openssh-server\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} apt-get update;\n ${SUDO} apt-get -y install ${PACKAGES};\n }\n ${SUDO} sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd\n\n# Fedora 23\n###########\nelif echo ${LINUX_TYPE} | grep -qi \"fedora\"; then\n command -v ps >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" procps-ng\"; }\n command -v sshd >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" openssh-server\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} dnf -y install ${PACKAGES};\n }\n ${SUDO} sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd\n\n# CentOS 7.1 & Oracle Linux 7.1\n###############################\nelif echo ${LINUX_TYPE} | grep -qi \"centos\"; then\n command -v sshd >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" openssh-server\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} yum -y install ${PACKAGES};\n }\n ${SUDO} sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd\n\n# openSUSE 13.2\n###############\nelif echo ${LINUX_TYPE} | grep -qi \"opensuse\"; then\n command -v sshd >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" openSSH\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} zypper install -y ${PACKAGES};\n }\n ${SUDO} sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd\n\n# Alpine 3.3\n############$$\nelif echo ${LINUX_TYPE} | grep -qi \"alpine\"; then\n command -v sshd >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" openssh\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} apk update;\n ${SUDO} apk add openssh ${PACKAGES};\n }\n\n# Centos 6.6, 6.7, 6.8\n############\nelif echo ${LINUX_TYPE} | grep -qi \"CentOS\"; then\n command -v sshd >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" openssh-server\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} yum -y install ${PACKAGES};\n }\n ${SUDO} sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd\n\nelse\n >&2 echo \"Unrecognized Linux Type\"\n >&2 cat $FILE\n exit 1\nfi\n\ncommand -v pidof >/dev/null 2>&1 && {\n pidof sshd >/dev/null 2>&1 && exit\n} || {\n ps -fC sshd >/dev/null 2>&1 && exit\n}\n\n\n${SUDO} mkdir -p /var/run/sshd\n\nif echo ${LINUX_TYPE} | grep -qi \"CentOS\"; then\n ${SUDO} /usr/bin/ssh-keygen -q -P '' -t rsa -f ~/.ssh/id_rsa\nelse\n ${SUDO} /usr/bin/ssh-keygen -A\nfi\n\n${SUDO} /usr/sbin/sshd -D\n"
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,8 +0,0 @@
|
|||
{
|
||||
"id": "org.eclipse.che.unison",
|
||||
"name": "File Sync",
|
||||
"description": "Unison File Synchronizer",
|
||||
"dependencies": [],
|
||||
"properties": {},
|
||||
"script" : "#\n# Copyright (c) 2012-2017 Codenvy, S.A.\n# All rights reserved. This program and the accompanying materials\n# are made available under the terms of the Eclipse Public License v1.0\n# which accompanies this distribution, and is available at\n# http://www.eclipse.org/legal/epl-v10.html\n#\n# Contributors:\n# Codenvy, S.A. - initial API and implementation\n#\n\nunset SUDO\nunset PACKAGES\ntest \"$(id -u)\" = 0 || SUDO=\"sudo\"\n\nif [ -f /etc/centos-release ]; then\n FILE=\"/etc/centos-release\"\n LINUX_TYPE=$(cat $FILE | awk '{print $1}')\n elif [ -f /etc/redhat-release ]; then\n FILE=\"/etc/redhat-release\"\n LINUX_TYPE=$(cat $FILE | cut -c 1-8)\n else\n FILE=\"/etc/os-release\"\n LINUX_TYPE=$(cat $FILE | grep ^ID= | tr '[:upper:]' '[:lower:]')\n LINUX_VERSION=$(cat $FILE | grep ^VERSION_ID=)\nfi\n\n###############################\n### Install Needed packaged ###\n###############################\n\n# Red Hat Enterprise Linux 7 \n############################\nif echo ${LINUX_TYPE} | grep -qi \"rhel\"; then\n command -v unison >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" unison\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} yum -y install ${PACKAGES};\n }\n\n# Red Hat Enterprise Linux 6 \n############################\nelif echo ${LINUX_TYPE} | grep -qi \"Red Hat\"; then\n command -v unison >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" unison\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} yum -y install ${PACKAGES};\n }\n\n# Ubuntu 14.04 16.04 / Linux Mint 17 \n####################################\nelif echo ${LINUX_TYPE} | grep -qi \"ubuntu\"; then\n command -v unison >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" unison\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} apt-get update;\n ${SUDO} apt-get -y install ${PACKAGES};\n }\n\n# Debian 8\n##########\nelif echo ${LINUX_TYPE} | grep -qi \"debian\"; then\n command -v unison >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" unison\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} apt-get update;\n ${SUDO} apt-get -y install ${PACKAGES};\n }\n\n# Fedora 23\n###########\nelif echo ${LINUX_TYPE} | grep -qi \"fedora\"; then\n command -v ps >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" procps-ng\"; }\n command -v unison >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" unison\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} dnf -y install ${PACKAGES};\n }\n\n# CentOS 7.1 & Oracle Linux 7.1\n###############################\nelif echo ${LINUX_TYPE} | grep -qi \"centos\"; then\n command -v unison >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" unison\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} yum -y install ${PACKAGES};\n }\n\n# openSUSE 13.2\n###############\nelif echo ${LINUX_TYPE} | grep -qi \"opensuse\"; then\n command -v unison >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" unison\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} zypper install -y ${PACKAGES};\n }\n\n# Alpine 3.3\n############$$\nelif echo ${LINUX_TYPE} | grep -qi \"alpine\"; then\n command -v unison >/dev/null 2>&1 || { PACKAGES=${PACKAGES}\" unison\"; }\n test \"${PACKAGES}\" = \"\" || {\n ${SUDO} apk update;\n ${SUDO} apk add ${PACKAGES};\n }\n\nelse\n >&2 echo \"Unrecognized Linux Type\"\n >&2 cat /etc/os-release\n exit 1\nfi"
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,39 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# Codenvy, S.A. - initial API and implementation
|
||||
#
|
||||
|
||||
updateAgentScript() {
|
||||
local DIR=$1
|
||||
local AGENT=$2
|
||||
local SCRIPT=$(cat ${AGENT}.script.sh | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g')
|
||||
|
||||
touch ${AGENT}.json.tmp
|
||||
cat ${DIR}/${AGENT}.json | while read line
|
||||
do
|
||||
if echo ${line} | grep -qi "\"script\""; then
|
||||
echo \"script\" : \"${SCRIPT}\" >> ${AGENT}.json.tmp
|
||||
else
|
||||
echo ${line} >> ${AGENT}.json.tmp
|
||||
fi
|
||||
done
|
||||
|
||||
mv ${AGENT}.json.tmp ${DIR}/${AGENT}.json
|
||||
}
|
||||
|
||||
updateAgentScript ".." "org.eclipse.che.ssh"
|
||||
updateAgentScript ".." "org.eclipse.che.terminal"
|
||||
updateAgentScript ".." "org.eclipse.che.ws-agent"
|
||||
updateAgentScript ".." "org.eclipse.che.ls.json"
|
||||
updateAgentScript ".." "org.eclipse.che.ls.csharp"
|
||||
updateAgentScript ".." "org.eclipse.che.ls.php"
|
||||
updateAgentScript ".." "org.eclipse.che.unison"
|
||||
updateAgentScript ".." "org.eclipse.che.ls.typescript"
|
||||
updateAgentScript ".." "org.eclipse.che.ls.python"
|
||||
|
|
@ -10,10 +10,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent.server.impl;
|
||||
|
||||
import org.eclipse.che.api.agent.server.model.impl.AgentKeyImpl;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.AgentKeyImpl;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.AssertJUnit.assertEquals;
|
||||
|
||||
/**
|
||||
|
|
@ -34,7 +33,7 @@ public class AgentKeyImplTest {
|
|||
AgentKeyImpl agentKey = AgentKeyImpl.parse("id");
|
||||
|
||||
assertEquals(agentKey.getId(), "id");
|
||||
assertNull(agentKey.getVersion());
|
||||
assertEquals(agentKey.getVersion(), "latest");
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,102 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent.server.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import org.eclipse.che.api.agent.server.AgentRegistry;
|
||||
import org.eclipse.che.api.agent.shared.dto.AgentDto;
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.AgentKeyImpl;
|
||||
import org.eclipse.che.dto.server.DtoFactory;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Anatolii Bazko
|
||||
*/
|
||||
public class AgentRegistryImplTest {
|
||||
|
||||
private AgentRegistry registry;
|
||||
|
||||
@BeforeMethod
|
||||
public void setUp() throws Exception {
|
||||
registry = new AgentRegistryImpl(new HashSet<Agent>() {{
|
||||
add(DtoFactory.newDto(AgentDto.class).withId("id1").withVersion("v1").withName("id1:v1"));
|
||||
add(DtoFactory.newDto(AgentDto.class).withId("id1").withVersion("v2").withName("id1:v2"));
|
||||
add(DtoFactory.newDto(AgentDto.class).withId("id2").withName("id2:latest"));
|
||||
add(DtoFactory.newDto(AgentDto.class).withId("id3").withVersion("v1").withName("id3:v1"));
|
||||
add(DtoFactory.newDto(AgentDto.class).withId("id3").withName("id3:latest"));
|
||||
}});
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void shouldNotRegisterAgentWithSameIdAndVersion() throws Exception {
|
||||
new AgentRegistryImpl(new HashSet<Agent>() {{
|
||||
add(DtoFactory.newDto(AgentDto.class).withId("id1").withVersion("v1").withScript("s1"));
|
||||
add(DtoFactory.newDto(AgentDto.class).withId("id1").withVersion("v1").withScript("s2"));
|
||||
}});
|
||||
}
|
||||
|
||||
@Test(dataProvider = "versions")
|
||||
public void shouldReturnVersionsById(String id, Set<String> expectedVersions) throws Exception {
|
||||
List<String> versions = registry.getVersions(id);
|
||||
|
||||
assertEquals(versions.size(), expectedVersions.size());
|
||||
for (String v : expectedVersions) {
|
||||
assertTrue(versions.contains(v));
|
||||
}
|
||||
}
|
||||
|
||||
@DataProvider(name = "versions")
|
||||
public static Object[][] versions() {
|
||||
return new Object[][] {{"id1", ImmutableSet.of("v1", "v2")},
|
||||
{"id2", ImmutableSet.of("latest")},
|
||||
{"id3", ImmutableSet.of("v1", "latest")}};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnAllAgents() throws Exception {
|
||||
Collection<Agent> agents = registry.getAgents();
|
||||
|
||||
assertEquals(agents.size(), 5);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "AgentKeys")
|
||||
public void shouldReturnAgentByIdAndVersion(String id, String version) throws Exception {
|
||||
Agent agent = registry.getAgent(new AgentKeyImpl(id, version));
|
||||
|
||||
assertNotNull(agent);
|
||||
assertEquals(agent.getName(), String.format("%s:%s", id, (version == null ? "latest" : version)));
|
||||
}
|
||||
|
||||
|
||||
@DataProvider(name = "AgentKeys")
|
||||
public static Object[][] AgentKeys() {
|
||||
return new String[][] {{"id1", "v1"},
|
||||
{"id1", "v2"},
|
||||
{"id2", null},
|
||||
{"id2", "latest"},
|
||||
{"id3", "v1"},
|
||||
{"id3", null},
|
||||
{"id3", "latest"}};
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ package org.eclipse.che.api.agent.server.impl;
|
|||
import org.eclipse.che.api.agent.server.AgentRegistry;
|
||||
import org.eclipse.che.api.agent.server.exception.AgentException;
|
||||
import org.eclipse.che.api.agent.server.exception.AgentNotFoundException;
|
||||
import org.eclipse.che.api.agent.server.model.impl.AgentKeyImpl;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.AgentKeyImpl;
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.agent.shared.model.AgentKey;
|
||||
import org.mockito.InjectMocks;
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent.server.impl;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.everrest.assured.EverrestJetty;
|
||||
import org.mockito.testng.MockitoTestNGListener;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Listeners;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.testng.AssertJUnit.assertFalse;
|
||||
|
||||
/**
|
||||
* @author Anatoliy Bazko
|
||||
*/
|
||||
@Listeners(value = {EverrestJetty.class, MockitoTestNGListener.class})
|
||||
public class LocalAgentRegistryImplTest {
|
||||
|
||||
private LocalAgentRegistryImpl agentRegistry;
|
||||
|
||||
@BeforeMethod
|
||||
public void setUp() throws Exception {
|
||||
agentRegistry = new LocalAgentRegistryImpl(Collections.emptySet());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitializeAgents() throws Exception {
|
||||
Collection<Agent> agents = agentRegistry.getAgents();
|
||||
assertFalse(agents.isEmpty());
|
||||
}
|
||||
}
|
||||
|
|
@ -23,6 +23,40 @@
|
|||
<properties>
|
||||
<go.workspace.name>go-workspace</go.workspace.name>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.inject</groupId>
|
||||
<artifactId>guice</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-agent</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-agent-shared</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-machine</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-workspace</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.BasicAgent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Exec agent.
|
||||
*
|
||||
* @see Agent
|
||||
*
|
||||
* @author Anatolii Bazko
|
||||
*/
|
||||
@Singleton
|
||||
public class ExecAgent extends BasicAgent {
|
||||
private static final String AGENT_DESCRIPTOR = "org.eclipse.che.terminal.json";
|
||||
private static final String AGENT_SCRIPT = "org.eclipse.che.terminal.script.sh";
|
||||
|
||||
@Inject
|
||||
public ExecAgent() throws IOException {
|
||||
super(AGENT_DESCRIPTOR, AGENT_SCRIPT);
|
||||
}
|
||||
}
|
||||
|
|
@ -8,36 +8,32 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.workspace.server.launcher;
|
||||
package org.eclipse.che.api.agent;
|
||||
|
||||
import org.eclipse.che.api.agent.server.launcher.AbstractAgentLauncher;
|
||||
import org.eclipse.che.api.agent.server.launcher.ProcessIsLaunchedChecker;
|
||||
import org.eclipse.che.api.agent.server.model.impl.AgentImpl;
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.AgentImpl;
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.machine.server.spi.Instance;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* Starts terminal agent.
|
||||
* Starts exec agent.
|
||||
*
|
||||
* @author Anatolii Bazko
|
||||
*/
|
||||
@Singleton
|
||||
public class TerminalAgentLauncherImpl extends AbstractAgentLauncher {
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(TerminalAgentLauncherImpl.class);
|
||||
|
||||
public class ExecAgentLauncher extends AbstractAgentLauncher {
|
||||
private final String runCommand;
|
||||
|
||||
@Inject
|
||||
public TerminalAgentLauncherImpl(@Named("che.agent.dev.max_start_time_ms") long agentMaxStartTimeMs,
|
||||
@Named("che.agent.dev.ping_delay_ms") long agentPingDelayMs,
|
||||
@Named("machine.terminal_agent.run_command") String runCommand) {
|
||||
public ExecAgentLauncher(@Named("che.agent.dev.max_start_time_ms") long agentMaxStartTimeMs,
|
||||
@Named("che.agent.dev.ping_delay_ms") long agentPingDelayMs,
|
||||
@Named("machine.terminal_agent.run_command") String runCommand) {
|
||||
super(agentMaxStartTimeMs, agentPingDelayMs, new ProcessIsLaunchedChecker("che-websocket-terminal"));
|
||||
this.runCommand = runCommand;
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.plugin.machine.ssh;
|
||||
package org.eclipse.che.api.agent;
|
||||
|
||||
import org.eclipse.che.api.agent.server.terminal.WebsocketTerminalFilesPathProvider;
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
|
|
@ -19,7 +19,6 @@ import org.eclipse.che.api.machine.server.exception.MachineException;
|
|||
import org.eclipse.che.api.machine.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.api.machine.server.spi.Instance;
|
||||
import org.eclipse.che.api.machine.server.spi.InstanceProcess;
|
||||
import org.eclipse.che.api.workspace.server.launcher.TerminalAgentLauncherImpl;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
|
@ -31,13 +30,13 @@ import static java.lang.String.format;
|
|||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
/**
|
||||
* Launch websocket terminal in ssh machines.
|
||||
* Launch exec agent in ssh machines.
|
||||
*
|
||||
* @author Alexander Garagatyi
|
||||
* @author Anatolii Bazko
|
||||
*/
|
||||
public class SshMachineImplTerminalLauncher extends TerminalAgentLauncherImpl {
|
||||
private static final Logger LOG = getLogger(SshMachineImplTerminalLauncher.class);
|
||||
public class SshMachineExecAgentLauncher extends ExecAgentLauncher {
|
||||
private static final Logger LOG = getLogger(SshMachineExecAgentLauncher.class);
|
||||
|
||||
// Regex to parse output of command 'uname -sm'
|
||||
// Consists of:
|
||||
|
|
@ -51,11 +50,11 @@ public class SshMachineImplTerminalLauncher extends TerminalAgentLauncherImpl {
|
|||
private final String terminalLocation;
|
||||
|
||||
@Inject
|
||||
public SshMachineImplTerminalLauncher(@Named("che.agent.dev.max_start_time_ms") long agentMaxStartTimeMs,
|
||||
@Named("che.agent.dev.ping_delay_ms") long agentPingDelayMs,
|
||||
@Named("machine.ssh.server.terminal.location") String terminalLocation,
|
||||
@Named("machine.terminal_agent.run_command") String terminalRunCommand,
|
||||
WebsocketTerminalFilesPathProvider terminalPathProvider) {
|
||||
public SshMachineExecAgentLauncher(@Named("che.agent.dev.max_start_time_ms") long agentMaxStartTimeMs,
|
||||
@Named("che.agent.dev.ping_delay_ms") long agentPingDelayMs,
|
||||
@Named("machine.ssh.server.terminal.location") String terminalLocation,
|
||||
@Named("machine.terminal_agent.run_command") String terminalRunCommand,
|
||||
WebsocketTerminalFilesPathProvider terminalPathProvider) {
|
||||
super(agentMaxStartTimeMs, agentPingDelayMs, terminalRunCommand);
|
||||
this.archivePathProvider = terminalPathProvider;
|
||||
this.terminalLocation = terminalLocation;
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"id": "org.eclipse.che.terminal",
|
||||
"name": "Terminal",
|
||||
"description": "Embedded web terminal",
|
||||
"dependencies": [],
|
||||
"properties": {},
|
||||
"servers": {
|
||||
"terminal": {
|
||||
"port": "4411/tcp",
|
||||
"protocol": "http"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -159,13 +159,13 @@ else
|
|||
fi
|
||||
|
||||
|
||||
if curl -o /dev/null --silent --head --fail $(echo ${AGENT_BINARIES_URI} | sed 's/\\${PREFIX}/'${PREFIX}'/g'); then
|
||||
curl -o $(echo ${TARGET_AGENT_BINARIES_URI} | sed 's/\\${PREFIX}/'${PREFIX}'/g' | sed 's/file:\\/\\///g') -s $(echo ${AGENT_BINARIES_URI} | sed 's/\\${PREFIX}/'${PREFIX}'/g')
|
||||
elif curl -o /dev/null --silent --head --fail $(echo ${AGENT_BINARIES_URI} | sed 's/-\\${PREFIX}//g'); then
|
||||
curl -o $(echo ${TARGET_AGENT_BINARIES_URI} | sed 's/\\${PREFIX}/'${PREFIX}'/g' | sed 's/file:\\/\\///g') -s $(echo ${AGENT_BINARIES_URI} | sed 's/-\\${PREFIX}//g')
|
||||
if curl -o /dev/null --silent --head --fail $(echo ${AGENT_BINARIES_URI} | sed 's/\${PREFIX}/'${PREFIX}'/g'); then
|
||||
curl -o $(echo ${TARGET_AGENT_BINARIES_URI} | sed 's/\${PREFIX}/'${PREFIX}'/g' | sed 's/file:\/\///g') -s $(echo ${AGENT_BINARIES_URI} | sed 's/\${PREFIX}/'${PREFIX}'/g')
|
||||
elif curl -o /dev/null --silent --head --fail $(echo ${AGENT_BINARIES_URI} | sed 's/-\${PREFIX}//g'); then
|
||||
curl -o $(echo ${TARGET_AGENT_BINARIES_URI} | sed 's/\${PREFIX}/'${PREFIX}'/g' | sed 's/file:\/\///g') -s $(echo ${AGENT_BINARIES_URI} | sed 's/-\${PREFIX}//g')
|
||||
fi
|
||||
|
||||
curl -s $(echo ${TARGET_AGENT_BINARIES_URI} | sed 's/\\${PREFIX}/'${PREFIX}'/g') | tar xzf - -C ${CHE_DIR}
|
||||
curl -s $(echo ${TARGET_AGENT_BINARIES_URI} | sed 's/\${PREFIX}/'${PREFIX}'/g') | tar xzf - -C ${CHE_DIR}
|
||||
|
||||
if [ -f /bin/bash ]; then
|
||||
SHELL_INTERPRETER="/bin/bash"
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Eclipse Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
Contributors:
|
||||
Codenvy, S.A. - initial API and implementation
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>che-agents-parent</artifactId>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<version>5.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>ls-csharp-agent</artifactId>
|
||||
<name>Language Server C# Agent</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.inject</groupId>
|
||||
<artifactId>guice</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-agent-shared</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.BasicAgent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Language server C# agent.
|
||||
*
|
||||
* @see Agent
|
||||
*
|
||||
* @author Anatolii Bazko
|
||||
*/
|
||||
@Singleton
|
||||
public class LSCSharpAgent extends BasicAgent {
|
||||
private static final String AGENT_DESCRIPTOR = "org.eclipse.che.ls.csharp.json";
|
||||
private static final String AGENT_SCRIPT = "org.eclipse.che.ls.csharp.script.sh";
|
||||
|
||||
@Inject
|
||||
public LSCSharpAgent() throws IOException {
|
||||
super(AGENT_DESCRIPTOR, AGENT_SCRIPT);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"id": "org.eclipse.che.ls.csharp",
|
||||
"name": "C# language server",
|
||||
"description": "C# intellisense",
|
||||
"dependencies": [],
|
||||
"properties": {}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Eclipse Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
Contributors:
|
||||
Codenvy, S.A. - initial API and implementation
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>che-agents-parent</artifactId>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<version>5.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>ls-json-agent</artifactId>
|
||||
<name>Language Server Json Agent</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.inject</groupId>
|
||||
<artifactId>guice</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-agent-shared</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.BasicAgent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Language server Json agent.
|
||||
*
|
||||
* @see Agent
|
||||
*
|
||||
* @author Anatolii Bazko
|
||||
*/
|
||||
@Singleton
|
||||
public class LSJsonAgent extends BasicAgent {
|
||||
private static final String AGENT_DESCRIPTOR = "org.eclipse.che.ls.json.json";
|
||||
private static final String AGENT_SCRIPT = "org.eclipse.che.ls.json.script.sh";
|
||||
|
||||
@Inject
|
||||
public LSJsonAgent() throws IOException {
|
||||
super(AGENT_DESCRIPTOR, AGENT_SCRIPT);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"id": "org.eclipse.che.ls.json",
|
||||
"name": "JSON language server",
|
||||
"description": "JSON intellisense",
|
||||
"dependencies": [],
|
||||
"properties": {}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Eclipse Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
Contributors:
|
||||
Codenvy, S.A. - initial API and implementation
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>che-agents-parent</artifactId>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<version>5.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>ls-php-agent</artifactId>
|
||||
<name>Language Server PHP Agent</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.inject</groupId>
|
||||
<artifactId>guice</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-agent-shared</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.BasicAgent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Language server Php agent.
|
||||
*
|
||||
* @see Agent
|
||||
*
|
||||
* @author Anatolii Bazko
|
||||
*/
|
||||
@Singleton
|
||||
public class LSPhpAgent extends BasicAgent {
|
||||
private static final String AGENT_DESCRIPTOR = "org.eclipse.che.ls.php.json";
|
||||
private static final String AGENT_SCRIPT = "org.eclipse.che.ls.php.script.sh";
|
||||
|
||||
@Inject
|
||||
public LSPhpAgent() throws IOException {
|
||||
super(AGENT_DESCRIPTOR, AGENT_SCRIPT);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"id": "org.eclipse.che.ls.php",
|
||||
"name": "PHP language server",
|
||||
"description": "PHP intellisense",
|
||||
"dependencies": [],
|
||||
"properties": {}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Eclipse Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
Contributors:
|
||||
Codenvy, S.A. - initial API and implementation
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>che-agents-parent</artifactId>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<version>5.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>ls-python-agent</artifactId>
|
||||
<name>Language Server python Agent</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.inject</groupId>
|
||||
<artifactId>guice</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-agent-shared</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.BasicAgent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Language server python agent.
|
||||
*
|
||||
* @see Agent
|
||||
*
|
||||
* @author Anatolii Bazko
|
||||
*/
|
||||
@Singleton
|
||||
public class LSPythonAgent extends BasicAgent {
|
||||
private static final String AGENT_DESCRIPTOR = "org.eclipse.che.ls.python.json";
|
||||
private static final String AGENT_SCRIPT = "org.eclipse.che.ls.python.script.sh";
|
||||
|
||||
@Inject
|
||||
public LSPythonAgent() throws IOException {
|
||||
super(AGENT_DESCRIPTOR, AGENT_SCRIPT);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"id": "org.eclipse.che.ls.python",
|
||||
"name": "Python language server",
|
||||
"description": "Python intellisense",
|
||||
"dependencies": [],
|
||||
"properties": {}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Eclipse Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
Contributors:
|
||||
Codenvy, S.A. - initial API and implementation
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>che-agents-parent</artifactId>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<version>5.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>ls-typescript-agent</artifactId>
|
||||
<name>Language Server typescript Agent</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.inject</groupId>
|
||||
<artifactId>guice</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-agent-shared</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.BasicAgent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Language server typescript agent.
|
||||
*
|
||||
* @see Agent
|
||||
*
|
||||
* @author Anatolii Bazko
|
||||
*/
|
||||
@Singleton
|
||||
public class LSTypeScriptAgent extends BasicAgent {
|
||||
private static final String AGENT_DESCRIPTOR = "org.eclipse.che.ls.typescript.json";
|
||||
private static final String AGENT_SCRIPT = "org.eclipse.che.ls.typescript.script.sh";
|
||||
|
||||
@Inject
|
||||
public LSTypeScriptAgent() throws IOException {
|
||||
super(AGENT_DESCRIPTOR, AGENT_SCRIPT);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"id": "org.eclipse.che.ls.js-ts",
|
||||
"name": "TypeScript language server",
|
||||
"description": "TypeScript intellisense",
|
||||
"dependencies": [],
|
||||
"properties": {}
|
||||
}
|
||||
|
|
@ -26,7 +26,14 @@
|
|||
<name>Che Agents Parent</name>
|
||||
<modules>
|
||||
<module>exec</module>
|
||||
<module>ssh</module>
|
||||
<module>unison</module>
|
||||
<module>che-core-api-agent-shared</module>
|
||||
<module>che-core-api-agent</module>
|
||||
<module>ls-json</module>
|
||||
<module>ls-php</module>
|
||||
<module>ls-python</module>
|
||||
<module>ls-typescript</module>
|
||||
<module>ls-csharp</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Eclipse Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
Contributors:
|
||||
Codenvy, S.A. - initial API and implementation
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>che-agents-parent</artifactId>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<version>5.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>ssh-agent</artifactId>
|
||||
<name>SSH Agent</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.inject</groupId>
|
||||
<artifactId>guice</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-agent</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-agent-shared</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -8,20 +8,30 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent.server;
|
||||
package org.eclipse.che.api.agent;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.multibindings.Multibinder;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.BasicAgent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Ssh agent.
|
||||
*
|
||||
* @see Agent
|
||||
*
|
||||
* @author Anatolii Bazko
|
||||
*/
|
||||
public class AgentModule extends AbstractModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(AgentRegistryService.class);
|
||||
Multibinder<Agent> agentsMultibinder = Multibinder.newSetBinder(binder(), Agent.class);
|
||||
@Singleton
|
||||
public class SshAgent extends BasicAgent {
|
||||
private static final String AGENT_DESCRIPTOR = "org.eclipse.che.ssh.json";
|
||||
private static final String AGENT_SCRIPT = "org.eclipse.che.ssh.script.sh";
|
||||
|
||||
@Inject
|
||||
public SshAgent() throws IOException {
|
||||
super(AGENT_DESCRIPTOR, AGENT_SCRIPT);
|
||||
}
|
||||
}
|
||||
|
|
@ -8,18 +8,17 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.workspace.server.launcher;
|
||||
package org.eclipse.che.api.agent;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.che.api.agent.server.launcher.AbstractAgentLauncher;
|
||||
import org.eclipse.che.api.agent.server.launcher.CompositeAgentLaunchingChecker;
|
||||
import org.eclipse.che.api.agent.server.launcher.MappedPortIsListeningAgentChecker;
|
||||
import org.eclipse.che.api.agent.server.launcher.ProcessIsLaunchedChecker;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* Starts SSH agent.
|
||||
|
|
@ -28,12 +27,10 @@ import javax.inject.Singleton;
|
|||
* @author Alexander Garagatyi
|
||||
*/
|
||||
@Singleton
|
||||
public class SshAgentLauncherImpl extends AbstractAgentLauncher {
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(SshAgentLauncherImpl.class);
|
||||
|
||||
public class SshAgentLauncher extends AbstractAgentLauncher {
|
||||
@Inject
|
||||
public SshAgentLauncherImpl(@Named("che.agent.dev.max_start_time_ms") long agentMaxStartTimeMs,
|
||||
@Named("che.agent.dev.ping_delay_ms") long agentPingDelayMs) {
|
||||
public SshAgentLauncher(@Named("che.agent.dev.max_start_time_ms") long agentMaxStartTimeMs,
|
||||
@Named("che.agent.dev.ping_delay_ms") long agentPingDelayMs) {
|
||||
super(agentMaxStartTimeMs,
|
||||
agentPingDelayMs,
|
||||
new CompositeAgentLaunchingChecker(new ProcessIsLaunchedChecker("sshd"),
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"id": "org.eclipse.che.ssh",
|
||||
"name": "SSH",
|
||||
"description": "SSH server, key-pair generation",
|
||||
"dependencies": [],
|
||||
"properties": {},
|
||||
"servers": {
|
||||
"ssh": {
|
||||
"port": "22/tcp"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Eclipse Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
Contributors:
|
||||
Codenvy, S.A. - initial API and implementation
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>che-agents-parent</artifactId>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<version>5.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>unison-agent</artifactId>
|
||||
<name>Unison Agent</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.inject</groupId>
|
||||
<artifactId>guice</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-agent-shared</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.BasicAgent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Unison agent.
|
||||
*
|
||||
* @see Agent
|
||||
*
|
||||
* @author Anatolii Bazko
|
||||
*/
|
||||
@Singleton
|
||||
public class UnisonAgent extends BasicAgent {
|
||||
private static final String AGENT_DESCRIPTOR = "org.eclipse.che.unison.json";
|
||||
private static final String AGENT_SCRIPT = "org.eclipse.che.unison.script.sh";
|
||||
|
||||
@Inject
|
||||
public UnisonAgent() throws IOException {
|
||||
super(AGENT_DESCRIPTOR, AGENT_SCRIPT);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"id": "org.eclipse.che.unison",
|
||||
"name": "File Sync",
|
||||
"description": "Unison File Synchronizer",
|
||||
"dependencies": [],
|
||||
"properties": {}
|
||||
}
|
||||
|
|
@ -58,6 +58,38 @@
|
|||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<artifactId>exec-agent</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<artifactId>ls-csharp-agent</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<artifactId>ls-json-agent</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<artifactId>ls-php-agent</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<artifactId>ls-python-agent</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<artifactId>ls-typescript-agent</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<artifactId>ssh-agent</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<artifactId>unison-agent</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-agent</artifactId>
|
||||
|
|
@ -114,6 +146,10 @@
|
|||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-sql-schema</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>wsagent</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>wsmaster-local</artifactId>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,21 @@ import com.google.inject.AbstractModule;
|
|||
import com.google.inject.multibindings.Multibinder;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
import org.eclipse.che.api.agent.ExecAgent;
|
||||
import org.eclipse.che.api.agent.ExecAgentLauncher;
|
||||
import org.eclipse.che.api.agent.LSCSharpAgent;
|
||||
import org.eclipse.che.api.agent.LSJsonAgent;
|
||||
import org.eclipse.che.api.agent.LSPhpAgent;
|
||||
import org.eclipse.che.api.agent.LSPythonAgent;
|
||||
import org.eclipse.che.api.agent.LSTypeScriptAgent;
|
||||
import org.eclipse.che.api.agent.SshAgent;
|
||||
import org.eclipse.che.api.agent.SshAgentLauncher;
|
||||
import org.eclipse.che.api.agent.SshMachineExecAgentLauncher;
|
||||
import org.eclipse.che.api.agent.UnisonAgent;
|
||||
import org.eclipse.che.api.agent.WsAgent;
|
||||
import org.eclipse.che.api.agent.WsAgentLauncher;
|
||||
import org.eclipse.che.api.agent.server.launcher.AgentLauncher;
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.core.rest.CheJsonProvider;
|
||||
import org.eclipse.che.api.core.rest.MessageBodyAdapter;
|
||||
import org.eclipse.che.api.core.rest.MessageBodyAdapterInterceptor;
|
||||
|
|
@ -75,6 +89,7 @@ public class WsMasterModule extends AbstractModule {
|
|||
bind(org.eclipse.che.plugin.docker.machine.ext.DockerMachineTerminalChecker.class);
|
||||
bind(org.eclipse.che.everrest.EverrestDownloadFileResponseFilter.class);
|
||||
bind(org.eclipse.che.everrest.ETagResponseFilter.class);
|
||||
bind(org.eclipse.che.api.agent.server.AgentRegistryService.class);
|
||||
|
||||
bind(org.eclipse.che.security.oauth.OAuthAuthenticatorProvider.class)
|
||||
.to(org.eclipse.che.security.oauth.OAuthAuthenticatorProviderImpl.class);
|
||||
|
|
@ -84,9 +99,10 @@ public class WsMasterModule extends AbstractModule {
|
|||
|
||||
bind(org.eclipse.che.api.core.notification.WSocketEventBusServer.class);
|
||||
// additional ports for development of extensions
|
||||
Multibinder<org.eclipse.che.api.core.model.machine.ServerConf> machineServers = Multibinder.newSetBinder(binder(),
|
||||
org.eclipse.che.api.core.model.machine.ServerConf.class,
|
||||
Names.named("machine.docker.dev_machine.machine_servers"));
|
||||
Multibinder<org.eclipse.che.api.core.model.machine.ServerConf> machineServers
|
||||
= Multibinder.newSetBinder(binder(),
|
||||
org.eclipse.che.api.core.model.machine.ServerConf.class,
|
||||
Names.named("machine.docker.dev_machine.machine_servers"));
|
||||
machineServers.addBinding().toInstance(
|
||||
new org.eclipse.che.api.machine.server.model.impl.ServerConfImpl(Constants.WSAGENT_DEBUG_REFERENCE, "4403/tcp", "http",
|
||||
null));
|
||||
|
|
@ -99,6 +115,29 @@ public class WsMasterModule extends AbstractModule {
|
|||
.addBinding()
|
||||
.toInstance("predefined-recipes.json");
|
||||
|
||||
bind(org.eclipse.che.api.workspace.server.WorkspaceValidator.class)
|
||||
.to(org.eclipse.che.api.workspace.server.DefaultWorkspaceValidator.class);
|
||||
|
||||
bind(org.eclipse.che.api.workspace.server.event.MachineStateListener.class).asEagerSingleton();
|
||||
|
||||
// agents
|
||||
bind(org.eclipse.che.api.agent.server.AgentRegistry.class).to(org.eclipse.che.api.agent.server.impl.AgentRegistryImpl.class);
|
||||
Multibinder<Agent> agents = Multibinder.newSetBinder(binder(), Agent.class);
|
||||
agents.addBinding().to(SshAgent.class);
|
||||
agents.addBinding().to(UnisonAgent.class);
|
||||
agents.addBinding().to(ExecAgent.class);
|
||||
agents.addBinding().to(WsAgent.class);
|
||||
agents.addBinding().to(LSPhpAgent.class);
|
||||
agents.addBinding().to(LSPythonAgent.class);
|
||||
agents.addBinding().to(LSJsonAgent.class);
|
||||
agents.addBinding().to(LSCSharpAgent.class);
|
||||
agents.addBinding().to(LSTypeScriptAgent.class);
|
||||
|
||||
Multibinder<AgentLauncher> launchers = Multibinder.newSetBinder(binder(), AgentLauncher.class);
|
||||
launchers.addBinding().to(WsAgentLauncher.class);
|
||||
launchers.addBinding().to(ExecAgentLauncher.class);
|
||||
launchers.addBinding().to(SshMachineExecAgentLauncher.class);
|
||||
launchers.addBinding().to(SshAgentLauncher.class);
|
||||
|
||||
bindConstant().annotatedWith(Names.named("machine.ws_agent.run_command"))
|
||||
.to("export JPDA_ADDRESS=\"4403\" && ~/che/ws-agent/bin/catalina.sh jpda run");
|
||||
|
|
@ -108,18 +147,6 @@ public class WsMasterModule extends AbstractModule {
|
|||
"-cmd ${SHELL_INTERPRETER} " +
|
||||
"-static $HOME/che/terminal/ " +
|
||||
"-logs-dir $HOME/che/exec-agent/logs");
|
||||
bind(org.eclipse.che.api.workspace.server.WorkspaceValidator.class)
|
||||
.to(org.eclipse.che.api.workspace.server.DefaultWorkspaceValidator.class);
|
||||
|
||||
bind(org.eclipse.che.api.workspace.server.event.MachineStateListener.class).asEagerSingleton();
|
||||
|
||||
bind(org.eclipse.che.api.agent.server.AgentRegistry.class)
|
||||
.to(org.eclipse.che.api.agent.server.impl.LocalAgentRegistryImpl.class);
|
||||
|
||||
Multibinder<AgentLauncher> agentLaunchers = Multibinder.newSetBinder(binder(), AgentLauncher.class);
|
||||
agentLaunchers.addBinding().to(org.eclipse.che.api.workspace.server.launcher.WsAgentLauncherImpl.class);
|
||||
agentLaunchers.addBinding().to(org.eclipse.che.api.workspace.server.launcher.TerminalAgentLauncherImpl.class);
|
||||
agentLaunchers.addBinding().to(org.eclipse.che.api.workspace.server.launcher.SshAgentLauncherImpl.class);
|
||||
|
||||
bind(org.eclipse.che.api.deploy.WsMasterAnalyticsAddresser.class);
|
||||
|
||||
|
|
@ -134,7 +161,6 @@ public class WsMasterModule extends AbstractModule {
|
|||
install(new org.eclipse.che.api.core.util.FileCleaner.FileCleanerModule());
|
||||
install(new org.eclipse.che.plugin.docker.machine.local.LocalDockerModule());
|
||||
install(new org.eclipse.che.api.machine.server.MachineModule());
|
||||
install(new org.eclipse.che.api.agent.server.AgentModule());
|
||||
install(new org.eclipse.che.plugin.docker.machine.ext.DockerExtServerModule());
|
||||
install(new org.eclipse.che.swagger.deploy.DocsModule());
|
||||
install(new org.eclipse.che.plugin.machine.ssh.SshMachineModule());
|
||||
|
|
|
|||
|
|
@ -54,14 +54,6 @@
|
|||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>javax.ws.rs-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-agent</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-agent-shared</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-core</artifactId>
|
||||
|
|
@ -74,10 +66,6 @@
|
|||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-model</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-workspace</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-commons-annotations</artifactId>
|
||||
|
|
@ -86,10 +74,6 @@
|
|||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-commons-lang</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
|
|
|
|||
|
|
@ -40,9 +40,6 @@ public class SshMachineModule extends AbstractModule {
|
|||
|
||||
bindConstant().annotatedWith(Names.named("machine.ssh.server.terminal.location")).to("~/che");
|
||||
|
||||
Multibinder.newSetBinder(binder(), org.eclipse.che.api.agent.server.launcher.AgentLauncher.class)
|
||||
.addBinding().to(org.eclipse.che.plugin.machine.ssh.SshMachineImplTerminalLauncher.class);
|
||||
|
||||
Multibinder<org.eclipse.che.api.core.model.machine.ServerConf> machineServers =
|
||||
Multibinder.newSetBinder(binder(),
|
||||
org.eclipse.che.api.core.model.machine.ServerConf.class,
|
||||
|
|
|
|||
45
pom.xml
45
pom.xml
|
|
@ -96,6 +96,46 @@
|
|||
<type>tar.gz</type>
|
||||
<classifier>linux_arm7</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<artifactId>exec-agent</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<artifactId>ls-csharp-agent</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<artifactId>ls-json-agent</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<artifactId>ls-php-agent</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<artifactId>ls-python-agent</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<artifactId>ls-typescript-agent</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<artifactId>ssh-agent</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che</groupId>
|
||||
<artifactId>unison-agent</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-account</artifactId>
|
||||
|
|
@ -378,6 +418,11 @@
|
|||
<artifactId>che-core-sql-schema</artifactId>
|
||||
<version>${che.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>wsagent</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>wsagent-local</artifactId>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,94 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are made available under the terms of the Eclipse Public License v1.0
|
||||
which accompanies this distribution, and is available at
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
Contributors:
|
||||
Codenvy, S.A. - initial API and implementation
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>che-agent-parent</artifactId>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<version>5.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>wsagent</artifactId>
|
||||
<name>Workspace Agent</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.inject</groupId>
|
||||
<artifactId>guice</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-agent</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-agent-shared</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-machine</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-model</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-workspace</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-commons-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-commons-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockitong</groupId>
|
||||
<artifactId>mockitong</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.BasicAgent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Workspace agent.
|
||||
*
|
||||
* @see Agent
|
||||
*
|
||||
* @author Anatolii Bazko
|
||||
*/
|
||||
@Singleton
|
||||
public class WsAgent extends BasicAgent {
|
||||
private static final String AGENT_DESCRIPTOR = "org.eclipse.che.ws-agent.json";
|
||||
private static final String AGENT_SCRIPT = "org.eclipse.che.ws-agent.script.sh";
|
||||
|
||||
@Inject
|
||||
public WsAgent() throws IOException {
|
||||
super(AGENT_DESCRIPTOR, AGENT_SCRIPT);
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.workspace.server.launcher;
|
||||
package org.eclipse.che.api.agent;
|
||||
|
||||
import org.eclipse.che.api.agent.server.WsAgentPingRequestFactory;
|
||||
import org.eclipse.che.api.agent.server.launcher.AgentLauncher;
|
||||
|
|
@ -44,8 +44,8 @@ import static org.eclipse.che.api.workspace.shared.Constants.WS_AGENT_PROCESS_NA
|
|||
* @author Anatolii Bazko
|
||||
*/
|
||||
@Singleton
|
||||
public class WsAgentLauncherImpl implements AgentLauncher {
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(WsAgentLauncherImpl.class);
|
||||
public class WsAgentLauncher implements AgentLauncher {
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(WsAgentLauncher.class);
|
||||
|
||||
private static final String WS_AGENT_PROCESS_OUTPUT_CHANNEL = "workspace:%s:ext-server:output";
|
||||
protected static final String DEFAULT_WS_AGENT_RUN_COMMAND = "~/che/ws-agent/bin/catalina.sh run";
|
||||
|
|
@ -58,12 +58,12 @@ public class WsAgentLauncherImpl implements AgentLauncher {
|
|||
private final String wsAgentRunCommand;
|
||||
|
||||
@Inject
|
||||
public WsAgentLauncherImpl(Provider<MachineProcessManager> machineProcessManagerProvider,
|
||||
WsAgentPingRequestFactory wsAgentPingRequestFactory,
|
||||
@Nullable @Named("machine.ws_agent.run_command") String wsAgentRunCommand,
|
||||
@Named("che.workspace.agent.dev.max_start_time_ms") long wsAgentMaxStartTimeMs,
|
||||
@Named("che.workspace.agent.dev.ping_delay_ms") long wsAgentPingDelayMs,
|
||||
@Named("che.workspace.agent.dev.ping_timeout_error_msg") String pingTimedOutErrorMessage) {
|
||||
public WsAgentLauncher(Provider<MachineProcessManager> machineProcessManagerProvider,
|
||||
WsAgentPingRequestFactory wsAgentPingRequestFactory,
|
||||
@Nullable @Named("machine.ws_agent.run_command") String wsAgentRunCommand,
|
||||
@Named("che.workspace.agent.dev.max_start_time_ms") long wsAgentMaxStartTimeMs,
|
||||
@Named("che.workspace.agent.dev.ping_delay_ms") long wsAgentPingDelayMs,
|
||||
@Named("che.workspace.agent.dev.ping_timeout_error_msg") String pingTimedOutErrorMessage) {
|
||||
this.machineProcessManagerProvider = machineProcessManagerProvider;
|
||||
this.wsAgentPingRequestFactory = wsAgentPingRequestFactory;
|
||||
this.wsAgentMaxStartTimeMs = wsAgentMaxStartTimeMs;
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"id": "org.eclipse.che.ws-agent",
|
||||
"name": "Workspace API",
|
||||
"description": "Workspace API support",
|
||||
"dependencies": [
|
||||
"org.eclipse.che.terminal"
|
||||
],
|
||||
"properties": {},
|
||||
"servers": {
|
||||
"wsagent": {
|
||||
"port": "4401/tcp",
|
||||
"protocol": "http",
|
||||
"properties": {
|
||||
"path": "/api"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,219 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent;
|
||||
|
||||
import org.eclipse.che.api.agent.server.WsAgentPingRequestFactory;
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.core.BadRequestException;
|
||||
import org.eclipse.che.api.core.NotFoundException;
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.core.model.machine.Command;
|
||||
import org.eclipse.che.api.core.model.machine.Server;
|
||||
import org.eclipse.che.api.core.rest.HttpJsonRequest;
|
||||
import org.eclipse.che.api.core.rest.HttpJsonRequestFactory;
|
||||
import org.eclipse.che.api.core.rest.HttpJsonResponse;
|
||||
import org.eclipse.che.api.environment.server.MachineProcessManager;
|
||||
import org.eclipse.che.api.machine.server.exception.MachineException;
|
||||
import org.eclipse.che.api.machine.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.api.machine.server.model.impl.MachineRuntimeInfoImpl;
|
||||
import org.eclipse.che.api.machine.server.model.impl.ServerImpl;
|
||||
import org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl;
|
||||
import org.eclipse.che.api.machine.server.spi.Instance;
|
||||
import org.eclipse.che.api.machine.shared.Constants;
|
||||
import org.eclipse.che.commons.test.mockito.answer.SelfReturningAnswer;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.testng.MockitoTestNGListener;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Listeners;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.eclipse.che.api.workspace.shared.Constants.WS_AGENT_PROCESS_NAME;
|
||||
|
||||
@Listeners(MockitoTestNGListener.class)
|
||||
public class WsAgentLauncherTest {
|
||||
private static final String MACHINE_ID = "machineId";
|
||||
private static final String WORKSPACE_ID = "testWorkspaceId";
|
||||
private static final String WS_AGENT_PORT = Constants.WS_AGENT_PORT;
|
||||
private static final long WS_AGENT_MAX_START_TIME_MS = 1000;
|
||||
private static final long WS_AGENT_PING_DELAY_MS = 1;
|
||||
private static final String WS_AGENT_SERVER_LOCATION = "ws-agent.com:456789/";
|
||||
private static final String WS_AGENT_SERVER_URL = "http://" + WS_AGENT_SERVER_LOCATION;
|
||||
private static final String WS_AGENT_SERVER_LOCATION_EXT = "ws-agent-ext.com:456789/";
|
||||
private static final String WS_AGENT_SERVER_URL_EXT = "http://" + WS_AGENT_SERVER_LOCATION;
|
||||
private static final ServerPropertiesImpl SERVER_PROPERTIES = new ServerPropertiesImpl(null,
|
||||
WS_AGENT_SERVER_LOCATION,
|
||||
WS_AGENT_SERVER_URL);
|
||||
private static final ServerImpl SERVER = new ServerImpl("ref",
|
||||
"http",
|
||||
WS_AGENT_SERVER_LOCATION_EXT,
|
||||
WS_AGENT_SERVER_URL_EXT,
|
||||
SERVER_PROPERTIES);
|
||||
private static final String WS_AGENT_TIMED_OUT_MESSAGE = "timeout error message";
|
||||
|
||||
@Mock
|
||||
private MachineProcessManager machineProcessManager;
|
||||
@Mock
|
||||
private HttpJsonRequestFactory requestFactory;
|
||||
@Mock
|
||||
private Instance machine;
|
||||
@Mock
|
||||
private HttpJsonResponse pingResponse;
|
||||
@Mock
|
||||
private MachineRuntimeInfoImpl machineRuntime;
|
||||
@Mock
|
||||
private WsAgentPingRequestFactory wsAgentPingRequestFactory;
|
||||
@Mock
|
||||
private Agent agent;
|
||||
|
||||
private HttpJsonRequest pingRequest;
|
||||
private WsAgentLauncher wsAgentLauncher;
|
||||
|
||||
@BeforeMethod
|
||||
public void setUp() throws Exception {
|
||||
wsAgentLauncher = new WsAgentLauncher(() -> machineProcessManager,
|
||||
wsAgentPingRequestFactory, null,
|
||||
WS_AGENT_MAX_START_TIME_MS,
|
||||
WS_AGENT_PING_DELAY_MS,
|
||||
WS_AGENT_TIMED_OUT_MESSAGE
|
||||
);
|
||||
pingRequest = Mockito.mock(HttpJsonRequest.class, new SelfReturningAnswer());
|
||||
Mockito.when(agent.getScript()).thenReturn("script");
|
||||
Mockito.when(machine.getId()).thenReturn(MACHINE_ID);
|
||||
Mockito.when(machine.getWorkspaceId()).thenReturn(WORKSPACE_ID);
|
||||
Mockito.when(machine.getRuntime()).thenReturn(machineRuntime);
|
||||
Mockito.doReturn(Collections.<String, Server>singletonMap(WS_AGENT_PORT, SERVER)).when(machineRuntime).getServers();
|
||||
Mockito.when(requestFactory.fromUrl(Matchers.anyString())).thenReturn(pingRequest);
|
||||
Mockito.when(wsAgentPingRequestFactory.createRequest(machine)).thenReturn(pingRequest);
|
||||
Mockito.when(pingRequest.request()).thenReturn(pingResponse);
|
||||
Mockito.when(pingResponse.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldStartWsAgentUsingMachineExec() throws Exception {
|
||||
wsAgentLauncher.launch(machine, agent);
|
||||
|
||||
Mockito.verify(machineProcessManager).exec(Matchers.eq(WORKSPACE_ID),
|
||||
Matchers.eq(MACHINE_ID),
|
||||
Matchers.eq(new CommandImpl("org.eclipse.che.ws-agent",
|
||||
"script\n" +
|
||||
WsAgentLauncher.DEFAULT_WS_AGENT_RUN_COMMAND,
|
||||
WS_AGENT_PROCESS_NAME)),
|
||||
Matchers.eq(WsAgentLauncher.getWsAgentProcessOutputChannel(WORKSPACE_ID)));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldPingWsAgentAfterStart() throws Exception {
|
||||
wsAgentLauncher.launch(machine, agent);
|
||||
|
||||
Mockito.verify(pingRequest).request();
|
||||
Mockito.verify(pingResponse).getResponseCode();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldPingWsAgentMultipleTimesAfterStartIfPingFailsWithException() throws Exception {
|
||||
Mockito.when(pingRequest.request()).thenThrow(new ServerException(""),
|
||||
new BadRequestException(""),
|
||||
new IOException())
|
||||
.thenReturn(pingResponse);
|
||||
|
||||
wsAgentLauncher.launch(machine, agent);
|
||||
|
||||
Mockito.verify(pingRequest, Mockito.times(4)).request();
|
||||
Mockito.verify(pingResponse).getResponseCode();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldPingWsAgentMultipleTimesAfterStartIfPingReturnsNotOKResponseCode() throws Exception {
|
||||
Mockito.when(pingResponse.getResponseCode()).thenReturn(HttpURLConnection.HTTP_CREATED,
|
||||
HttpURLConnection.HTTP_NO_CONTENT,
|
||||
HttpURLConnection.HTTP_OK);
|
||||
|
||||
wsAgentLauncher.launch(machine, agent);
|
||||
|
||||
Mockito.verify(pingRequest, Mockito.times(3)).request();
|
||||
Mockito.verify(pingResponse, Mockito.times(3)).getResponseCode();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotPingWsAgentAfterFirstSuccessfulPing() throws Exception {
|
||||
Mockito.when(pingRequest.request()).thenThrow(new ServerException(""))
|
||||
.thenReturn(pingResponse);
|
||||
|
||||
wsAgentLauncher.launch(machine, agent);
|
||||
|
||||
Mockito.verify(pingRequest, Mockito.times(2)).request();
|
||||
Mockito.verify(pingResponse).getResponseCode();
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "Test exception")
|
||||
public void shouldThrowMachineExceptionIfMachineManagerExecInDevMachineThrowsNotFoundException() throws Exception {
|
||||
Mockito.when(machineProcessManager.exec(Matchers.anyString(),
|
||||
Matchers.anyString(),
|
||||
Matchers.any(Command.class),
|
||||
Matchers.anyString()))
|
||||
.thenThrow(new NotFoundException("Test exception"));
|
||||
|
||||
wsAgentLauncher.launch(machine, agent);
|
||||
|
||||
Mockito.verify(machineProcessManager).exec(Matchers.anyString(),
|
||||
Matchers.anyString(),
|
||||
Matchers.any(Command.class),
|
||||
Matchers.anyString());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "Test exception")
|
||||
public void shouldThrowMachineExceptionIfMachineManagerExecInDevMachineThrowsMachineException() throws Exception {
|
||||
Mockito.when(machineProcessManager.exec(Matchers.anyString(),
|
||||
Matchers.anyString(),
|
||||
Matchers.any(Command.class),
|
||||
Matchers.anyString()))
|
||||
.thenThrow(new MachineException("Test exception"));
|
||||
|
||||
wsAgentLauncher.launch(machine, agent);
|
||||
|
||||
Mockito.verify(machineProcessManager).exec(Matchers.anyString(),
|
||||
Matchers.anyString(),
|
||||
Matchers.any(Command.class),
|
||||
Matchers.anyString());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "Test exception")
|
||||
public void shouldThrowExceptionIfMachineManagerExecInDevMachineThrowsBadRequestException() throws Exception {
|
||||
Mockito.when(machineProcessManager.exec(Matchers.anyString(),
|
||||
Matchers.anyString(),
|
||||
Matchers.any(Command.class),
|
||||
Matchers.anyString()))
|
||||
.thenThrow(new BadRequestException("Test exception"));
|
||||
|
||||
wsAgentLauncher.launch(machine, agent);
|
||||
|
||||
Mockito.verify(machineProcessManager).exec(Matchers.anyString(),
|
||||
Matchers.anyString(),
|
||||
Matchers.any(Command.class),
|
||||
Matchers.anyString());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ServerException.class,
|
||||
expectedExceptionsMessageRegExp = WS_AGENT_TIMED_OUT_MESSAGE)
|
||||
public void shouldThrowMachineExceptionIfPingsWereUnsuccessfulTooLong() throws Exception {
|
||||
Mockito.when(pingRequest.request()).thenThrow(new ServerException(""));
|
||||
|
||||
wsAgentLauncher.launch(machine, agent);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -25,6 +25,7 @@
|
|||
<packaging>pom</packaging>
|
||||
<name>Che Agent Parent</name>
|
||||
<modules>
|
||||
<module>agent</module>
|
||||
<module>che-core-api-project-shared</module>
|
||||
<module>che-core-api-project</module>
|
||||
<module>che-core-api-git</module>
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ import com.google.common.base.Strings;
|
|||
|
||||
import org.eclipse.che.api.agent.server.AgentRegistry;
|
||||
import org.eclipse.che.api.agent.server.exception.AgentException;
|
||||
import org.eclipse.che.api.agent.server.model.impl.AgentImpl;
|
||||
import org.eclipse.che.api.agent.server.model.impl.AgentKeyImpl;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.AgentImpl;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.AgentKeyImpl;
|
||||
import org.eclipse.che.api.core.ApiException;
|
||||
import org.eclipse.che.api.core.ConflictException;
|
||||
import org.eclipse.che.api.core.NotFoundException;
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ import com.google.common.collect.ImmutableMap;
|
|||
import org.eclipse.che.api.agent.server.AgentRegistry;
|
||||
import org.eclipse.che.api.agent.server.impl.AgentSorter;
|
||||
import org.eclipse.che.api.agent.server.launcher.AgentLauncherFactory;
|
||||
import org.eclipse.che.api.agent.server.model.impl.AgentImpl;
|
||||
import org.eclipse.che.api.agent.server.model.impl.AgentKeyImpl;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.AgentImpl;
|
||||
import org.eclipse.che.api.agent.shared.model.impl.AgentKeyImpl;
|
||||
import org.eclipse.che.api.core.model.workspace.ServerConf2;
|
||||
import org.eclipse.che.api.environment.server.model.CheServiceImpl;
|
||||
import org.eclipse.che.api.machine.server.spi.Instance;
|
||||
|
|
|
|||
|
|
@ -1,224 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012-2017 Codenvy, S.A.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.workspace.server.launcher;
|
||||
|
||||
import org.eclipse.che.api.agent.server.WsAgentPingRequestFactory;
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.core.BadRequestException;
|
||||
import org.eclipse.che.api.core.NotFoundException;
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.core.model.machine.Command;
|
||||
import org.eclipse.che.api.core.model.machine.Server;
|
||||
import org.eclipse.che.api.core.rest.HttpJsonRequest;
|
||||
import org.eclipse.che.api.core.rest.HttpJsonRequestFactory;
|
||||
import org.eclipse.che.api.core.rest.HttpJsonResponse;
|
||||
import org.eclipse.che.api.environment.server.MachineProcessManager;
|
||||
import org.eclipse.che.api.machine.server.exception.MachineException;
|
||||
import org.eclipse.che.api.machine.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.api.machine.server.model.impl.MachineRuntimeInfoImpl;
|
||||
import org.eclipse.che.api.machine.server.model.impl.ServerImpl;
|
||||
import org.eclipse.che.api.machine.server.model.impl.ServerPropertiesImpl;
|
||||
import org.eclipse.che.api.machine.server.spi.Instance;
|
||||
import org.eclipse.che.api.machine.shared.Constants;
|
||||
import org.eclipse.che.commons.test.mockito.answer.SelfReturningAnswer;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.testng.MockitoTestNGListener;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Listeners;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.eclipse.che.api.workspace.shared.Constants.WS_AGENT_PROCESS_NAME;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@Listeners(MockitoTestNGListener.class)
|
||||
public class WsAgentLauncherImplTest {
|
||||
private static final String MACHINE_ID = "machineId";
|
||||
private static final String WORKSPACE_ID = "testWorkspaceId";
|
||||
private static final String WS_AGENT_PORT = Constants.WS_AGENT_PORT;
|
||||
private static final long WS_AGENT_MAX_START_TIME_MS = 1000;
|
||||
private static final long WS_AGENT_PING_DELAY_MS = 1;
|
||||
private static final String WS_AGENT_SERVER_LOCATION = "ws-agent.com:456789/";
|
||||
private static final String WS_AGENT_SERVER_URL = "http://" + WS_AGENT_SERVER_LOCATION;
|
||||
private static final String WS_AGENT_SERVER_LOCATION_EXT = "ws-agent-ext.com:456789/";
|
||||
private static final String WS_AGENT_SERVER_URL_EXT = "http://" + WS_AGENT_SERVER_LOCATION;
|
||||
private static final ServerPropertiesImpl SERVER_PROPERTIES = new ServerPropertiesImpl(null,
|
||||
WS_AGENT_SERVER_LOCATION,
|
||||
WS_AGENT_SERVER_URL);
|
||||
private static final ServerImpl SERVER = new ServerImpl("ref",
|
||||
"http",
|
||||
WS_AGENT_SERVER_LOCATION_EXT,
|
||||
WS_AGENT_SERVER_URL_EXT,
|
||||
SERVER_PROPERTIES);
|
||||
private static final String WS_AGENT_TIMED_OUT_MESSAGE = "timeout error message";
|
||||
|
||||
@Mock
|
||||
private MachineProcessManager machineProcessManager;
|
||||
@Mock
|
||||
private HttpJsonRequestFactory requestFactory;
|
||||
@Mock
|
||||
private Instance machine;
|
||||
@Mock
|
||||
private HttpJsonResponse pingResponse;
|
||||
@Mock
|
||||
private MachineRuntimeInfoImpl machineRuntime;
|
||||
@Mock
|
||||
private WsAgentPingRequestFactory wsAgentPingRequestFactory;
|
||||
@Mock
|
||||
private Agent agent;
|
||||
|
||||
private HttpJsonRequest pingRequest;
|
||||
private WsAgentLauncherImpl wsAgentLauncher;
|
||||
|
||||
@BeforeMethod
|
||||
public void setUp() throws Exception {
|
||||
wsAgentLauncher = new WsAgentLauncherImpl(() -> machineProcessManager,
|
||||
wsAgentPingRequestFactory, null,
|
||||
WS_AGENT_MAX_START_TIME_MS,
|
||||
WS_AGENT_PING_DELAY_MS,
|
||||
WS_AGENT_TIMED_OUT_MESSAGE
|
||||
);
|
||||
pingRequest = Mockito.mock(HttpJsonRequest.class, new SelfReturningAnswer());
|
||||
when(agent.getScript()).thenReturn("script");
|
||||
when(machine.getId()).thenReturn(MACHINE_ID);
|
||||
when(machine.getWorkspaceId()).thenReturn(WORKSPACE_ID);
|
||||
when(machine.getRuntime()).thenReturn(machineRuntime);
|
||||
doReturn(Collections.<String, Server>singletonMap(WS_AGENT_PORT, SERVER)).when(machineRuntime).getServers();
|
||||
when(requestFactory.fromUrl(anyString())).thenReturn(pingRequest);
|
||||
when(wsAgentPingRequestFactory.createRequest(machine)).thenReturn(pingRequest);
|
||||
when(pingRequest.request()).thenReturn(pingResponse);
|
||||
when(pingResponse.getResponseCode()).thenReturn(HttpURLConnection.HTTP_OK);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldStartWsAgentUsingMachineExec() throws Exception {
|
||||
wsAgentLauncher.launch(machine, agent);
|
||||
|
||||
verify(machineProcessManager).exec(eq(WORKSPACE_ID),
|
||||
eq(MACHINE_ID),
|
||||
eq(new CommandImpl("org.eclipse.che.ws-agent",
|
||||
"script\n" + WsAgentLauncherImpl.DEFAULT_WS_AGENT_RUN_COMMAND,
|
||||
WS_AGENT_PROCESS_NAME)),
|
||||
eq(WsAgentLauncherImpl.getWsAgentProcessOutputChannel(WORKSPACE_ID)));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldPingWsAgentAfterStart() throws Exception {
|
||||
wsAgentLauncher.launch(machine, agent);
|
||||
|
||||
verify(pingRequest).request();
|
||||
verify(pingResponse).getResponseCode();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldPingWsAgentMultipleTimesAfterStartIfPingFailsWithException() throws Exception {
|
||||
when(pingRequest.request()).thenThrow(new ServerException(""),
|
||||
new BadRequestException(""),
|
||||
new IOException())
|
||||
.thenReturn(pingResponse);
|
||||
|
||||
wsAgentLauncher.launch(machine, agent);
|
||||
|
||||
verify(pingRequest, times(4)).request();
|
||||
verify(pingResponse).getResponseCode();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldPingWsAgentMultipleTimesAfterStartIfPingReturnsNotOKResponseCode() throws Exception {
|
||||
when(pingResponse.getResponseCode()).thenReturn(HttpURLConnection.HTTP_CREATED,
|
||||
HttpURLConnection.HTTP_NO_CONTENT,
|
||||
HttpURLConnection.HTTP_OK);
|
||||
|
||||
wsAgentLauncher.launch(machine, agent);
|
||||
|
||||
verify(pingRequest, times(3)).request();
|
||||
verify(pingResponse, times(3)).getResponseCode();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotPingWsAgentAfterFirstSuccessfulPing() throws Exception {
|
||||
when(pingRequest.request()).thenThrow(new ServerException(""))
|
||||
.thenReturn(pingResponse);
|
||||
|
||||
wsAgentLauncher.launch(machine, agent);
|
||||
|
||||
verify(pingRequest, times(2)).request();
|
||||
verify(pingResponse).getResponseCode();
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "Test exception")
|
||||
public void shouldThrowMachineExceptionIfMachineManagerExecInDevMachineThrowsNotFoundException() throws Exception {
|
||||
when(machineProcessManager.exec(anyString(),
|
||||
anyString(),
|
||||
any(Command.class),
|
||||
anyString()))
|
||||
.thenThrow(new NotFoundException("Test exception"));
|
||||
|
||||
wsAgentLauncher.launch(machine, agent);
|
||||
|
||||
verify(machineProcessManager).exec(anyString(),
|
||||
anyString(),
|
||||
any(Command.class),
|
||||
anyString());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "Test exception")
|
||||
public void shouldThrowMachineExceptionIfMachineManagerExecInDevMachineThrowsMachineException() throws Exception {
|
||||
when(machineProcessManager.exec(anyString(),
|
||||
anyString(),
|
||||
any(Command.class),
|
||||
anyString()))
|
||||
.thenThrow(new MachineException("Test exception"));
|
||||
|
||||
wsAgentLauncher.launch(machine, agent);
|
||||
|
||||
verify(machineProcessManager).exec(anyString(),
|
||||
anyString(),
|
||||
any(Command.class),
|
||||
anyString());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "Test exception")
|
||||
public void shouldThrowExceptionIfMachineManagerExecInDevMachineThrowsBadRequestException() throws Exception {
|
||||
when(machineProcessManager.exec(anyString(),
|
||||
anyString(),
|
||||
any(Command.class),
|
||||
anyString()))
|
||||
.thenThrow(new BadRequestException("Test exception"));
|
||||
|
||||
wsAgentLauncher.launch(machine, agent);
|
||||
|
||||
verify(machineProcessManager).exec(anyString(),
|
||||
anyString(),
|
||||
any(Command.class),
|
||||
anyString());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ServerException.class,
|
||||
expectedExceptionsMessageRegExp = WS_AGENT_TIMED_OUT_MESSAGE)
|
||||
public void shouldThrowMachineExceptionIfPingsWereUnsuccessfulTooLong() throws Exception {
|
||||
when(pingRequest.request()).thenThrow(new ServerException(""));
|
||||
|
||||
wsAgentLauncher.launch(machine, agent);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue