Remove che-core-api-machine module
Signed-off-by: Alexander Garagatyi <agaragatyi@codenvy.com>6.19.x
parent
bac363f5ff
commit
5e95640fd6
|
|
@ -59,10 +59,6 @@
|
|||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-dto</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>
|
||||
|
|
|
|||
|
|
@ -21,10 +21,6 @@ import org.eclipse.che.api.core.model.workspace.config.Command;
|
|||
import org.eclipse.che.api.core.util.AbstractLineConsumer;
|
||||
import org.eclipse.che.api.core.util.LineConsumer;
|
||||
import org.eclipse.che.api.core.util.ListLineConsumer;
|
||||
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.commons.lang.concurrent.LoggingUncaughtExceptionHandler;
|
||||
import org.eclipse.che.commons.lang.concurrent.ThreadLocalPropagateContext;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -69,7 +65,7 @@ public abstract class AbstractAgentLauncher implements AgentLauncher {
|
|||
this.agentLaunchingChecker = agentLaunchingChecker;
|
||||
}
|
||||
|
||||
@Override
|
||||
/*@Override
|
||||
public void launch(Instance machine, Agent agent) throws ServerException, AgentStartException {
|
||||
if (isNullOrEmpty(agent.getScript())) {
|
||||
return;
|
||||
|
|
@ -160,6 +156,6 @@ public abstract class AbstractAgentLauncher implements AgentLauncher {
|
|||
machine.getId(),
|
||||
machine.getNode());
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ package org.eclipse.che.api.agent.server.launcher;
|
|||
import org.eclipse.che.api.agent.server.exception.AgentStartException;
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.machine.server.spi.Instance;
|
||||
|
||||
/**
|
||||
* Launches {@link Agent#getScript()} on the {@link Instance}.
|
||||
|
|
@ -48,5 +47,5 @@ public interface AgentLauncher {
|
|||
* @throws ServerException
|
||||
* if script execution failed
|
||||
*/
|
||||
void launch(Instance machine, Agent agent) throws ServerException, AgentStartException;
|
||||
// void launch(Instance machine, Agent agent) throws ServerException, AgentStartException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,17 +10,12 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent.server.launcher;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.machine.server.exception.MachineException;
|
||||
import org.eclipse.che.api.machine.server.spi.Instance;
|
||||
import org.eclipse.che.api.machine.server.spi.InstanceProcess;
|
||||
|
||||
/**
|
||||
* Indicates if agent finished working.
|
||||
*
|
||||
* @author Anatoliy Bazko
|
||||
*/
|
||||
@FunctionalInterface
|
||||
//@FunctionalInterface
|
||||
public interface AgentLaunchingChecker {
|
||||
|
||||
/**
|
||||
|
|
@ -35,7 +30,7 @@ public interface AgentLaunchingChecker {
|
|||
* @throws MachineException
|
||||
* if unexpected error is occurred
|
||||
*/
|
||||
boolean isLaunched(Agent agent, InstanceProcess process, Instance machine) throws MachineException;
|
||||
|
||||
AgentLaunchingChecker DEFAULT = (agent, process, machine) -> !process.isAlive();
|
||||
// boolean isLaunched(Agent agent, InstanceProcess process, Instance machine) throws MachineException;
|
||||
//
|
||||
// AgentLaunchingChecker DEFAULT = (agent, process, machine) -> !process.isAlive();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,15 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent.server.launcher;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.core.ConflictException;
|
||||
import org.eclipse.che.api.core.model.workspace.config.Command;
|
||||
import org.eclipse.che.api.core.util.ListLineConsumer;
|
||||
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 static java.lang.String.format;
|
||||
|
||||
/**
|
||||
|
|
@ -37,7 +28,7 @@ public class CommandExistsAgentChecker implements AgentLaunchingChecker {
|
|||
this.checkingCommand = format(CHECK_COMMAND, commandToCheck);
|
||||
}
|
||||
|
||||
@Override
|
||||
/*@Override
|
||||
public boolean isLaunched(Agent agent, InstanceProcess process, Instance machine) throws MachineException {
|
||||
Command command = new CommandImpl(format("Wait for %s, try %d", agent.getId(), ++counter),
|
||||
checkingCommand,
|
||||
|
|
@ -50,5 +41,5 @@ public class CommandExistsAgentChecker implements AgentLaunchingChecker {
|
|||
} catch (ConflictException e) {
|
||||
throw new MachineException(e.getServiceError());
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent.server.launcher;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.machine.server.exception.MachineException;
|
||||
import org.eclipse.che.api.machine.server.spi.Instance;
|
||||
import org.eclipse.che.api.machine.server.spi.InstanceProcess;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -41,7 +36,7 @@ public class CompositeAgentLaunchingChecker implements AgentLaunchingChecker {
|
|||
this.agentLaunchingCheckers = Arrays.asList(agentLaunchingCheckers);
|
||||
}
|
||||
|
||||
@Override
|
||||
/*@Override
|
||||
public boolean isLaunched(Agent agent, InstanceProcess process, Instance machine) throws MachineException {
|
||||
for (AgentLaunchingChecker agentLaunchingChecker : agentLaunchingCheckers) {
|
||||
if (!agentLaunchingChecker.isLaunched(agent, process, machine)) {
|
||||
|
|
@ -49,5 +44,5 @@ public class CompositeAgentLaunchingChecker implements AgentLaunchingChecker {
|
|||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,16 +13,6 @@ package org.eclipse.che.api.agent.server.launcher;
|
|||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.core.util.AbstractLineConsumer;
|
||||
import org.eclipse.che.api.core.util.LineConsumer;
|
||||
import org.eclipse.che.api.machine.server.spi.Instance;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
|
||||
/**
|
||||
* Launches agent and waits while it is finished.
|
||||
*
|
||||
|
|
@ -36,7 +26,7 @@ public class DefaultAgentLauncher implements AgentLauncher {
|
|||
@Inject
|
||||
public DefaultAgentLauncher() { }
|
||||
|
||||
@Override
|
||||
/*@Override
|
||||
public void launch(Instance machine, Agent agent) throws ServerException {
|
||||
if (isNullOrEmpty(agent.getScript())) {
|
||||
return;
|
||||
|
|
@ -69,7 +59,7 @@ public class DefaultAgentLauncher implements AgentLauncher {
|
|||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
*/
|
||||
@Override
|
||||
public String getAgentId() {
|
||||
return "any";
|
||||
|
|
|
|||
|
|
@ -10,12 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent.server.launcher;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Server;
|
||||
import org.eclipse.che.api.machine.server.exception.MachineException;
|
||||
import org.eclipse.che.api.machine.server.spi.Instance;
|
||||
import org.eclipse.che.api.machine.server.spi.InstanceProcess;
|
||||
|
||||
/**
|
||||
* Verifies that agent was started successfully by checking that specified local port is listened in a machine.
|
||||
*
|
||||
|
|
@ -28,7 +22,7 @@ public class MappedPortIsListeningAgentChecker implements AgentLaunchingChecker
|
|||
// normalize port/transport value
|
||||
this.exposedPort = exposedPort.contains("/") ? exposedPort : exposedPort + "/tcp";
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public boolean isLaunched(Agent agent, InstanceProcess process, Instance machine) throws MachineException {
|
||||
Server server = machine.getRuntime().getServers().get(exposedPort);
|
||||
|
|
@ -45,5 +39,5 @@ public class MappedPortIsListeningAgentChecker implements AgentLaunchingChecker
|
|||
// }
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,19 +10,14 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent.server.launcher;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.machine.server.exception.MachineException;
|
||||
import org.eclipse.che.api.machine.server.spi.Instance;
|
||||
import org.eclipse.che.api.machine.server.spi.InstanceProcess;
|
||||
|
||||
/**
|
||||
* Agent launching checker that does nothing. Useful when agent does not run in a machine as daemon.
|
||||
*
|
||||
* @author Alexander Garagatyi
|
||||
*/
|
||||
public class NoOpAgentLaunchingChecker implements AgentLaunchingChecker {
|
||||
@Override
|
||||
/*@Override
|
||||
public boolean isLaunched(Agent agent, InstanceProcess process, Instance machine) throws MachineException {
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,17 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.api.agent.server.launcher;
|
||||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.core.ConflictException;
|
||||
import org.eclipse.che.api.core.model.workspace.config.Command;
|
||||
import org.eclipse.che.api.core.util.ListLineConsumer;
|
||||
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 static java.lang.String.format;
|
||||
|
||||
/**
|
||||
* Verifies if agent started a process with specific name.
|
||||
* It is an indicator that process had been finished.
|
||||
|
|
@ -41,7 +30,7 @@ public class ProcessIsLaunchedChecker implements AgentLaunchingChecker {
|
|||
this.processNameToWait = processNameToWait;
|
||||
}
|
||||
|
||||
@Override
|
||||
/*@Override
|
||||
public boolean isLaunched(Agent agent, InstanceProcess process, Instance machine) throws MachineException {
|
||||
Command command = new CommandImpl(format("Wait for %s, try %d", agent.getId(), ++counter),
|
||||
format(CHECK_COMMAND, processNameToWait),
|
||||
|
|
@ -54,5 +43,5 @@ public class ProcessIsLaunchedChecker implements AgentLaunchingChecker {
|
|||
} catch (ConflictException e) {
|
||||
throw new MachineException(e.getServiceError());
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ import static org.mockito.Mockito.spy;
|
|||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
|
|
|||
|
|
@ -41,10 +41,6 @@
|
|||
<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>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
|
|
|||
|
|
@ -41,10 +41,6 @@
|
|||
<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>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
|
|
|||
|
|
@ -118,10 +118,6 @@
|
|||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-factory</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-project-templates</artifactId>
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@ import org.eclipse.che.api.factory.server.FactoryAcceptValidator;
|
|||
import org.eclipse.che.api.factory.server.FactoryCreateValidator;
|
||||
import org.eclipse.che.api.factory.server.FactoryEditValidator;
|
||||
import org.eclipse.che.api.factory.server.FactoryParametersResolver;
|
||||
import org.eclipse.che.api.recipe.JpaRecipeDao;
|
||||
import org.eclipse.che.api.recipe.RecipeDao;
|
||||
import org.eclipse.che.api.recipe.RecipeLoader;
|
||||
import org.eclipse.che.api.recipe.RecipeService;
|
||||
import org.eclipse.che.api.user.server.TokenValidator;
|
||||
import org.eclipse.che.api.workspace.server.RemoveWorkspaceFilesAfterRemoveWorkspaceEventSubscriber;
|
||||
import org.eclipse.che.api.workspace.server.adapter.StackMessageBodyAdapter;
|
||||
|
|
@ -42,6 +46,8 @@ import org.eclipse.che.inject.DynaModule;
|
|||
import org.eclipse.che.plugin.github.factory.resolver.GithubFactoryParametersResolver;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.DockerInfraModule;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.local.LocalDockerModule;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.snapshot.JpaSnapshotDao;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.snapshot.SnapshotDao;
|
||||
import org.flywaydb.core.internal.util.PlaceholderReplacer;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
|
@ -59,7 +65,10 @@ public class WsMasterModule extends AbstractModule {
|
|||
install(new org.eclipse.che.account.api.AccountModule());
|
||||
install(new org.eclipse.che.api.user.server.jpa.UserJpaModule());
|
||||
install(new org.eclipse.che.api.ssh.server.jpa.SshJpaModule());
|
||||
install(new org.eclipse.che.api.machine.server.jpa.MachineJpaModule());
|
||||
// install(new org.eclipse.che.api.machine.server.jpa.MachineJpaModule());
|
||||
bind(RecipeDao.class).to(JpaRecipeDao.class);
|
||||
// TODO spi move into docker infra impl
|
||||
bind(SnapshotDao.class).to(JpaSnapshotDao.class);
|
||||
install(new org.eclipse.che.api.workspace.server.jpa.WorkspaceJpaModule());
|
||||
install(new org.eclipse.che.api.core.jsonrpc.JsonRpcModule());
|
||||
install(new org.eclipse.che.api.core.websocket.WebSocketModule());
|
||||
|
|
@ -91,7 +100,7 @@ public class WsMasterModule extends AbstractModule {
|
|||
bind(org.eclipse.che.api.project.server.template.ProjectTemplateRegistry.class);
|
||||
bind(org.eclipse.che.api.project.server.template.ProjectTemplateService.class);
|
||||
bind(org.eclipse.che.api.ssh.server.SshService.class);
|
||||
bind(org.eclipse.che.api.machine.server.recipe.RecipeService.class);
|
||||
bind(RecipeService.class);
|
||||
bind(org.eclipse.che.api.user.server.UserService.class);
|
||||
bind(org.eclipse.che.api.user.server.ProfileService.class);
|
||||
bind(org.eclipse.che.api.user.server.PreferencesService.class);
|
||||
|
|
@ -127,7 +136,7 @@ public class WsMasterModule extends AbstractModule {
|
|||
bind(org.eclipse.che.api.agent.server.WsAgentHealthChecker.class)
|
||||
.to(org.eclipse.che.api.agent.server.WsAgentHealthCheckerImpl.class);
|
||||
|
||||
bind(org.eclipse.che.api.machine.server.recipe.RecipeLoader.class);
|
||||
bind(RecipeLoader.class);
|
||||
Multibinder.newSetBinder(binder(), String.class, Names.named("predefined.recipe.path"))
|
||||
.addBinding()
|
||||
.toInstance("predefined-recipes.json");
|
||||
|
|
@ -182,7 +191,7 @@ public class WsMasterModule extends AbstractModule {
|
|||
install(new org.eclipse.che.api.core.util.FileCleaner.FileCleanerModule());
|
||||
// FIXME: spi
|
||||
// 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.machine.server.MachineModule());
|
||||
// FIXME: spi
|
||||
// install(new org.eclipse.che.plugin.docker.machine.ext.DockerExtServerModule());
|
||||
install(new org.eclipse.che.swagger.deploy.DocsModule());
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@
|
|||
<class>org.eclipse.che.api.workspace.server.model.impl.ServerConfigImpl</class>
|
||||
<class>org.eclipse.che.api.workspace.server.model.impl.stack.StackImpl</class>
|
||||
|
||||
<class>org.eclipse.che.api.machine.server.model.impl.CommandImpl</class>
|
||||
<class>org.eclipse.che.api.machine.server.model.impl.MachineSourceImpl</class>
|
||||
<class>org.eclipse.che.api.machine.server.model.impl.SnapshotImpl</class>
|
||||
<class>org.eclipse.che.api.machine.server.recipe.OldRecipeImpl</class>
|
||||
<class>org.eclipse.che.api.workspace.server.model.impl.CommandImpl</class>
|
||||
<class>org.eclipse.che.api.workspace.server.model.impl.MachineSourceImpl</class>
|
||||
<class>org.eclipse.che.workspace.infrastructure.docker.snapshot.SnapshotImpl</class>
|
||||
<class>org.eclipse.che.api.recipe.OldRecipeImpl</class>
|
||||
|
||||
<class>org.eclipse.che.api.factory.server.model.impl.FactoryImpl</class>
|
||||
<class>org.eclipse.che.api.factory.server.model.impl.OnAppClosedImpl</class>
|
||||
|
|
|
|||
|
|
@ -78,10 +78,6 @@
|
|||
<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>
|
||||
|
|
@ -98,6 +94,30 @@
|
|||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-commons-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.persistence</groupId>
|
||||
<artifactId>eclipselink</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.persistence</groupId>
|
||||
<artifactId>javax.persistence</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.inject.extensions</groupId>
|
||||
<artifactId>guice-persist</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-db</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-commons-lang</artifactId>
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@ import org.eclipse.che.api.core.util.FileCleaner;
|
|||
import org.eclipse.che.api.core.util.LineConsumer;
|
||||
import org.eclipse.che.api.core.util.ListLineConsumer;
|
||||
import org.eclipse.che.api.core.util.SystemInfo;
|
||||
import org.eclipse.che.api.machine.server.exception.MachineException;
|
||||
import org.eclipse.che.api.machine.server.model.impl.MachineSourceImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.MachineSourceImpl;
|
||||
import org.eclipse.che.api.workspace.server.spi.InfrastructureException;
|
||||
import org.eclipse.che.api.workspace.server.spi.RuntimeIdentity;
|
||||
import org.eclipse.che.commons.annotation.Nullable;
|
||||
|
|
@ -324,7 +323,7 @@ public class ServiceStarter {
|
|||
String machineImageName,
|
||||
boolean doForcePullOnBuild,
|
||||
ProgressMonitor progressMonitor)
|
||||
throws MachineException {
|
||||
throws ServerException {
|
||||
|
||||
File workDir = null;
|
||||
try {
|
||||
|
|
@ -356,7 +355,7 @@ public class ServiceStarter {
|
|||
|
||||
docker.buildImage(buildImageParams, progressMonitor);
|
||||
} catch (IOException e) {
|
||||
throw new MachineException(e.getLocalizedMessage(), e);
|
||||
throw new ServerException(e.getLocalizedMessage(), e);
|
||||
} finally {
|
||||
if (workDir != null) {
|
||||
FileCleaner.addFile(workDir);
|
||||
|
|
@ -375,16 +374,16 @@ public class ServiceStarter {
|
|||
* consumer of output
|
||||
* @throws SourceNotFoundException
|
||||
* if image for pulling not found
|
||||
* @throws MachineException
|
||||
* @throws ServerException
|
||||
* if any other error occurs
|
||||
*/
|
||||
protected void pullImage(DockerService service,
|
||||
String machineImageName,
|
||||
ProgressMonitor progressMonitor) throws MachineException, SourceNotFoundException {
|
||||
ProgressMonitor progressMonitor) throws ServerException, SourceNotFoundException {
|
||||
DockerMachineSource dockerMachineSource = new DockerMachineSource(
|
||||
new MachineSourceImpl("image").setLocation(service.getImage()));
|
||||
if (dockerMachineSource.getRepository() == null) {
|
||||
throw new MachineException(
|
||||
throw new ServerException(
|
||||
format("Machine creation failed. Machine source is invalid. No repository is defined. Found '%s'.",
|
||||
dockerMachineSource));
|
||||
}
|
||||
|
|
@ -413,7 +412,7 @@ public class ServiceStarter {
|
|||
docker.removeImage(RemoveImageParams.create(fullNameOfPulledImage).withForce(false));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new MachineException("Can't create machine from image. Cause: " + e.getLocalizedMessage(), e);
|
||||
throw new ServerException("Can't create machine from image. Cause: " + e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ package org.eclipse.che.workspace.infrastructure.docker.environment;
|
|||
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.core.model.workspace.config.Environment;
|
||||
import org.eclipse.che.api.machine.server.util.RecipeDownloader;
|
||||
import org.eclipse.che.api.workspace.server.RecipeDownloader;
|
||||
import org.eclipse.che.api.workspace.server.spi.InfrastructureException;
|
||||
import org.eclipse.che.api.workspace.server.spi.RuntimeIdentity;
|
||||
import org.eclipse.che.commons.lang.NameGenerator;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import org.eclipse.che.api.core.ServerException;
|
|||
import org.eclipse.che.api.core.ValidationException;
|
||||
import org.eclipse.che.api.core.model.workspace.config.Environment;
|
||||
import org.eclipse.che.api.core.model.workspace.config.Recipe;
|
||||
import org.eclipse.che.api.machine.server.util.RecipeDownloader;
|
||||
import org.eclipse.che.api.workspace.server.RecipeDownloader;
|
||||
import org.eclipse.che.api.workspace.server.spi.InfrastructureException;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.environment.TypeSpecificEnvironmentParser;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.environment.compose.model.ComposeEnvironment;
|
||||
|
|
|
|||
|
|
@ -15,9 +15,8 @@ import com.google.common.cache.CacheBuilder;
|
|||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
|
||||
import org.eclipse.che.api.core.notification.EventService;
|
||||
import org.eclipse.che.commons.lang.concurrent.LoggingUncaughtExceptionHandler;
|
||||
import org.eclipse.che.api.machine.server.event.InstanceStateEvent;
|
||||
import org.eclipse.che.commons.lang.Pair;
|
||||
import org.eclipse.che.commons.lang.concurrent.LoggingUncaughtExceptionHandler;
|
||||
import org.eclipse.che.plugin.docker.client.DockerConnector;
|
||||
import org.eclipse.che.plugin.docker.client.DockerConnectorProvider;
|
||||
import org.eclipse.che.plugin.docker.client.MessageProcessor;
|
||||
|
|
@ -141,7 +140,7 @@ public class DockerInstanceStopDetector {
|
|||
LOG.info("OOM of process in container {} has been detected", message.getId());
|
||||
break;
|
||||
case "die":
|
||||
InstanceStateEvent.Type instanceStateChangeType;
|
||||
/*InstanceStateEvent.Type instanceStateChangeType;
|
||||
if (containersOomTimestamps.getIfPresent(message.getId()) != null) {
|
||||
instanceStateChangeType = InstanceStateEvent.Type.OOM;
|
||||
containersOomTimestamps.invalidate(message.getId());
|
||||
|
|
@ -155,7 +154,7 @@ public class DockerInstanceStopDetector {
|
|||
instanceIds.second,
|
||||
instanceStateChangeType));
|
||||
lastProcessedEventDate = message.getTime();
|
||||
}
|
||||
}*/
|
||||
break;
|
||||
default:
|
||||
// we don't care about other event types
|
||||
|
|
|
|||
|
|
@ -10,10 +10,8 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.workspace.infrastructure.docker.old;
|
||||
|
||||
import org.eclipse.che.api.machine.server.spi.Instance;
|
||||
|
||||
/**
|
||||
* Docker implementation of {@link Instance}
|
||||
* Docker implementation of {@link }
|
||||
*
|
||||
* @author andrew00x
|
||||
* @author Alexander Garagatyi
|
||||
|
|
|
|||
|
|
@ -15,19 +15,12 @@ import com.google.inject.Singleton;
|
|||
|
||||
import org.eclipse.che.api.core.NotFoundException;
|
||||
import org.eclipse.che.api.core.model.machine.MachineSource;
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.api.core.util.LineConsumer;
|
||||
import org.eclipse.che.api.machine.server.exception.InvalidRecipeException;
|
||||
import org.eclipse.che.api.machine.server.exception.MachineException;
|
||||
import org.eclipse.che.api.machine.server.exception.SnapshotException;
|
||||
import org.eclipse.che.api.machine.server.exception.UnsupportedRecipeException;
|
||||
import org.eclipse.che.api.machine.server.spi.Instance;
|
||||
import org.eclipse.che.api.machine.server.spi.InstanceProvider;
|
||||
import org.eclipse.che.commons.lang.IoUtil;
|
||||
import org.eclipse.che.plugin.docker.client.DockerConnector;
|
||||
import org.eclipse.che.plugin.docker.client.DockerConnectorProvider;
|
||||
import org.eclipse.che.plugin.docker.client.DockerRegistryAuthResolver;
|
||||
import org.eclipse.che.plugin.docker.client.params.RemoveImageParams;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.snapshot.SnapshotException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
@ -41,14 +34,13 @@ import java.net.URL;
|
|||
import static org.eclipse.che.plugin.docker.client.DockerRegistryAuthResolver.DEFAULT_REGISTRY_SYNONYMS;
|
||||
|
||||
/**
|
||||
* Docker implementation of {@link InstanceProvider}
|
||||
*
|
||||
* @author andrew00x
|
||||
* @author Alexander Garagatyi
|
||||
* @author Roman Iuvshyn
|
||||
* @author Mykola Morhun
|
||||
*
|
||||
* @deprecated use {@link MachineProviderImpl} instead
|
||||
* @deprecated use {@link } instead
|
||||
*/
|
||||
@Deprecated
|
||||
@Singleton
|
||||
|
|
@ -93,7 +85,7 @@ public class DockerInstanceProvider {
|
|||
* machine description
|
||||
* @param creationLogsOutput
|
||||
* output for instance creation logs
|
||||
* @return newly created {@link Instance}
|
||||
* @return newly created {@link }
|
||||
* @throws UnsupportedRecipeException
|
||||
* if specified {@code recipe} is not supported
|
||||
* @throws InvalidRecipeException
|
||||
|
|
@ -103,11 +95,11 @@ public class DockerInstanceProvider {
|
|||
* @throws MachineException
|
||||
* if other error occurs
|
||||
*/
|
||||
public Instance createInstance(Machine machine,
|
||||
/*public Instance createInstance(Machine machine,
|
||||
LineConsumer creationLogsOutput) throws NotFoundException,
|
||||
MachineException {
|
||||
Exception {
|
||||
throw new UnsupportedOperationException("This machine provider is deprecated.");
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Removes snapshot of the instance in implementation specific way.
|
||||
|
|
@ -123,7 +115,7 @@ public class DockerInstanceProvider {
|
|||
final DockerMachineSource dockerMachineSource;
|
||||
try {
|
||||
dockerMachineSource = new DockerMachineSource(machineSource);
|
||||
} catch (MachineException e) {
|
||||
} catch (Exception e) {
|
||||
throw new SnapshotException(e);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.workspace.infrastructure.docker.old;
|
||||
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.core.model.machine.MachineSource;
|
||||
import org.eclipse.che.api.machine.server.exception.MachineException;
|
||||
import org.eclipse.che.api.machine.server.model.impl.MachineSourceImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.MachineSourceImpl;
|
||||
import org.eclipse.che.plugin.docker.client.DockerFileException;
|
||||
import org.eclipse.che.plugin.docker.client.DockerRegistryAuthResolver;
|
||||
import org.eclipse.che.plugin.docker.client.parser.DockerImageIdentifier;
|
||||
|
|
@ -50,10 +50,10 @@ public class DockerMachineSource extends MachineSourceImpl {
|
|||
* Build a dedicated docker image source based on a given machine source object.
|
||||
* @param machineSource the machine source used to parse data.
|
||||
*/
|
||||
public DockerMachineSource(MachineSource machineSource) throws MachineException {
|
||||
public DockerMachineSource(MachineSource machineSource) throws ServerException {
|
||||
// check type
|
||||
if (!DockerInstanceProvider.DOCKER_IMAGE_TYPE.equals(machineSource.getType())) {
|
||||
throw new MachineException("Docker machine source can only be built with '" + DockerInstanceProvider.DOCKER_IMAGE_TYPE + "' type");
|
||||
throw new ServerException("Docker machine source can only be built with '" + DockerInstanceProvider.DOCKER_IMAGE_TYPE + "' type");
|
||||
}
|
||||
setType(DockerInstanceProvider.DOCKER_IMAGE_TYPE);
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ public class DockerMachineSource extends MachineSourceImpl {
|
|||
try {
|
||||
dockerImageIdentifier = DockerImageIdentifierParser.parse(machineSource.getLocation());
|
||||
} catch (DockerFileException e) {
|
||||
throw new MachineException("Try to build a docker machine source with an invalid location/content. It is not in the expected format", e);
|
||||
throw new ServerException("Try to build a docker machine source with an invalid location/content. It is not in the expected format", e);
|
||||
}
|
||||
|
||||
// populate
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import org.eclipse.che.api.agent.shared.model.Agent;
|
|||
import org.eclipse.che.api.core.model.workspace.config.Command;
|
||||
import org.eclipse.che.api.core.util.AbstractLineConsumer;
|
||||
import org.eclipse.che.api.core.util.LineConsumer;
|
||||
import org.eclipse.che.api.machine.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.api.workspace.server.spi.InfrastructureException;
|
||||
import org.eclipse.che.commons.lang.concurrent.LoggingUncaughtExceptionHandler;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.model.DockerService;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ package org.eclipse.che.workspace.infrastructure.docker.old.agents;
|
|||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.core.model.workspace.config.Command;
|
||||
import org.eclipse.che.api.machine.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.api.workspace.server.spi.InfrastructureException;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.model.DockerService;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,15 +14,6 @@ import com.google.inject.Inject;
|
|||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.che.api.agent.server.launcher.AgentLauncher;
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.core.util.AbstractLineConsumer;
|
||||
import org.eclipse.che.api.core.util.LineConsumer;
|
||||
import org.eclipse.che.api.machine.server.spi.Instance;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||
|
||||
/**
|
||||
* Launches agent and waits while it is finished.
|
||||
|
|
@ -37,7 +28,7 @@ public class DefaultAgentLauncher implements AgentLauncher {
|
|||
@Inject
|
||||
public DefaultAgentLauncher() { }
|
||||
|
||||
@Override
|
||||
/*@Override
|
||||
public void launch(Instance machine, Agent agent) throws ServerException {
|
||||
if (isNullOrEmpty(agent.getScript())) {
|
||||
return;
|
||||
|
|
@ -69,7 +60,7 @@ public class DefaultAgentLauncher implements AgentLauncher {
|
|||
// } catch (IOException ignored) {
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public String getAgentId() {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ package org.eclipse.che.workspace.infrastructure.docker.old.agents;
|
|||
|
||||
import org.eclipse.che.api.agent.shared.model.Agent;
|
||||
import org.eclipse.che.api.core.model.workspace.config.Command;
|
||||
import org.eclipse.che.api.machine.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.api.workspace.server.spi.InfrastructureException;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.model.DockerService;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import org.eclipse.che.api.core.ApiException;
|
|||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.core.rest.HttpJsonRequest;
|
||||
import org.eclipse.che.api.core.rest.HttpJsonResponse;
|
||||
import org.eclipse.che.api.machine.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.api.workspace.server.spi.InfrastructureException;
|
||||
import org.eclipse.che.commons.annotation.Nullable;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.model.DockerService;
|
||||
|
|
|
|||
|
|
@ -11,14 +11,13 @@
|
|||
package org.eclipse.che.workspace.infrastructure.docker.old.local.node;
|
||||
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.machine.server.spi.InstanceNode;
|
||||
|
||||
/**
|
||||
* Provides access to operation machines need but not supported by the Docker
|
||||
*
|
||||
* @author Alexander Garagatyi
|
||||
*/
|
||||
public interface DockerNode extends InstanceNode {
|
||||
public interface DockerNode {
|
||||
/**
|
||||
* Bind the whole workspace on the Node.
|
||||
*
|
||||
|
|
@ -35,7 +34,6 @@ public interface DockerNode extends InstanceNode {
|
|||
*/
|
||||
void unbindWorkspace() throws ServerException;
|
||||
|
||||
@Override
|
||||
String getHost();
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -8,15 +8,12 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.machine.server.jpa;
|
||||
package org.eclipse.che.workspace.infrastructure.docker.snapshot;
|
||||
|
||||
import com.google.inject.persist.Transactional;
|
||||
|
||||
import org.eclipse.che.api.core.NotFoundException;
|
||||
import org.eclipse.che.core.db.jpa.DuplicateKeyException;
|
||||
import org.eclipse.che.api.machine.server.exception.SnapshotException;
|
||||
import org.eclipse.che.api.machine.server.model.impl.SnapshotImpl;
|
||||
import org.eclipse.che.api.machine.server.spi.SnapshotDao;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
|
|
@ -98,11 +95,11 @@ public class JpaSnapshotDao implements SnapshotDao {
|
|||
try {
|
||||
doSave(snapshot);
|
||||
} catch (DuplicateKeyException x) {
|
||||
throw new SnapshotException(format("Snapshot with id '%s' or for machine '%s:%s:%s' already exists",
|
||||
snapshot.getId(),
|
||||
snapshot.getWorkspaceId(),
|
||||
snapshot.getEnvName(),
|
||||
snapshot.getMachineName()));
|
||||
throw new SnapshotException(String.format("Snapshot with id '%s' or for machine '%s:%s:%s' already exists",
|
||||
snapshot.getId(),
|
||||
snapshot.getWorkspaceId(),
|
||||
snapshot.getEnvName(),
|
||||
snapshot.getMachineName()));
|
||||
} catch (RuntimeException x) {
|
||||
throw new SnapshotException(x.getLocalizedMessage(), x);
|
||||
}
|
||||
|
|
@ -8,11 +8,9 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.machine.server.spi;
|
||||
package org.eclipse.che.workspace.infrastructure.docker.snapshot;
|
||||
|
||||
import org.eclipse.che.api.core.NotFoundException;
|
||||
import org.eclipse.che.api.machine.server.exception.SnapshotException;
|
||||
import org.eclipse.che.api.machine.server.model.impl.SnapshotImpl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package org.eclipse.che.workspace.infrastructure.docker.snapshot;
|
||||
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.core.rest.shared.dto.ServiceError;
|
||||
|
||||
/**
|
||||
* @author Alexander Garagatyi
|
||||
*/
|
||||
public class SnapshotException extends ServerException {
|
||||
public SnapshotException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public SnapshotException(ServiceError serviceError) {
|
||||
super(serviceError);
|
||||
}
|
||||
|
||||
public SnapshotException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public SnapshotException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
|
@ -8,12 +8,12 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.machine.server.model.impl;
|
||||
package org.eclipse.che.workspace.infrastructure.docker.snapshot;
|
||||
|
||||
import org.eclipse.che.api.core.model.machine.OldMachineConfig;
|
||||
import org.eclipse.che.api.core.model.machine.MachineSource;
|
||||
import org.eclipse.che.api.core.model.machine.OldMachineConfig;
|
||||
import org.eclipse.che.api.core.model.machine.Snapshot;
|
||||
import org.eclipse.che.api.machine.server.spi.Instance;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.MachineSourceImpl;
|
||||
import org.eclipse.che.commons.lang.NameGenerator;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
|
@ -26,7 +26,7 @@ import javax.persistence.Table;
|
|||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Saved state of {@link Instance}.
|
||||
* Saved state of {@link }.
|
||||
*
|
||||
* @author Yevhenii Voevodin
|
||||
*/
|
||||
|
|
@ -13,7 +13,7 @@ package org.eclipse.che.workspace.infrastructure.docker.strategy;
|
|||
import com.google.inject.Inject;
|
||||
import com.google.inject.name.Named;
|
||||
|
||||
import org.eclipse.che.api.machine.server.model.impl.ServerImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.ServerImpl;
|
||||
import org.eclipse.che.commons.annotation.Nullable;
|
||||
import org.eclipse.che.plugin.docker.client.json.ContainerInfo;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ package org.eclipse.che.workspace.infrastructure.docker.strategy;
|
|||
import com.google.inject.Inject;
|
||||
import com.google.inject.name.Named;
|
||||
|
||||
import org.eclipse.che.api.machine.server.model.impl.ServerImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.ServerImpl;
|
||||
import org.eclipse.che.commons.annotation.Nullable;
|
||||
import org.eclipse.che.plugin.docker.client.json.ContainerInfo;
|
||||
import org.eclipse.che.plugin.docker.client.json.PortBinding;
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@
|
|||
package org.eclipse.che.workspace.infrastructure.docker.strategy;
|
||||
|
||||
import org.eclipse.che.api.core.model.machine.ServerProperties;
|
||||
import org.eclipse.che.api.machine.server.model.impl.OldServerConfImpl;
|
||||
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.workspace.server.model.impl.OldServerConfImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.ServerImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.ServerPropertiesImpl;
|
||||
import org.eclipse.che.plugin.docker.client.json.ContainerInfo;
|
||||
import org.eclipse.che.plugin.docker.client.json.PortBinding;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ import org.eclipse.che.api.agent.server.launcher.AgentLauncherFactory;
|
|||
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.config.ServerConfig;
|
||||
import org.eclipse.che.api.machine.server.spi.Instance;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.MachineConfigImpl;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.model.DockerService;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.old.agents.AgentConfigApplier;
|
||||
|
|
@ -47,8 +46,8 @@ public class AgentConfigApplierTest {
|
|||
|
||||
@Mock
|
||||
private AgentSorter sorter;
|
||||
@Mock
|
||||
private Instance machine;
|
||||
// @Mock
|
||||
// private Instance machine;
|
||||
@Mock
|
||||
private AgentImpl agent1;
|
||||
@Mock
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.workspace.infrastructure.docker.environment.compose;
|
||||
|
||||
import org.eclipse.che.api.machine.server.util.RecipeDownloader;
|
||||
import org.eclipse.che.api.workspace.server.RecipeDownloader;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.environment.compose.model.ComposeEnvironment;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.environment.compose.model.ComposeService;
|
||||
import org.mockito.InjectMocks;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import com.google.common.collect.ImmutableMap;
|
|||
|
||||
import org.eclipse.che.api.core.model.workspace.config.Environment;
|
||||
import org.eclipse.che.api.core.model.workspace.config.Recipe;
|
||||
import org.eclipse.che.api.machine.server.util.RecipeDownloader;
|
||||
import org.eclipse.che.api.workspace.server.RecipeDownloader;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.model.DockerBuildContext;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.model.DockerEnvironment;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.model.DockerService;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ package org.eclipse.che.workspace.infrastructure.docker.environment.compose;
|
|||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import org.eclipse.che.api.machine.server.util.RecipeDownloader;
|
||||
import org.eclipse.che.api.workspace.server.RecipeDownloader;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.environment.compose.deserializer.EnvironmentDeserializer;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.environment.compose.model.ComposeEnvironment;
|
||||
import org.eclipse.che.workspace.infrastructure.docker.environment.compose.model.ComposeService;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ package org.eclipse.che.workspace.infrastructure.docker.old.integration;
|
|||
import org.eclipse.che.api.core.model.workspace.config.Command;
|
||||
import org.eclipse.che.api.core.util.LineConsumer;
|
||||
import org.eclipse.che.api.machine.server.exception.MachineException;
|
||||
import org.eclipse.che.api.machine.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.plugin.docker.client.DockerApiVersionPathPrefixProvider;
|
||||
import org.eclipse.che.plugin.docker.client.DockerConnector;
|
||||
import org.eclipse.che.plugin.docker.client.DockerConnectorConfiguration;
|
||||
|
|
|
|||
|
|
@ -8,16 +8,14 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.machine.server.jpa;
|
||||
package org.eclipse.che.workspace.infrastructure.docker.snapshot;
|
||||
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
import org.eclipse.che.account.spi.AccountImpl;
|
||||
import org.eclipse.che.api.core.model.workspace.Workspace;
|
||||
import org.eclipse.che.api.machine.server.model.impl.SnapshotImpl;
|
||||
import org.eclipse.che.api.machine.server.recipe.OldRecipeImpl;
|
||||
import org.eclipse.che.api.machine.server.spi.RecipeDao;
|
||||
import org.eclipse.che.api.machine.server.spi.SnapshotDao;
|
||||
import org.eclipse.che.commons.test.db.H2DBTestServer;
|
||||
import org.eclipse.che.commons.test.db.H2JpaCleaner;
|
||||
import org.eclipse.che.commons.test.db.H2TestHelper;
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.machine.server.spi.tck;
|
||||
package org.eclipse.che.workspace.infrastructure.docker.snapshot;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.Inject;
|
||||
|
|
@ -20,9 +20,7 @@ import org.eclipse.che.api.core.model.workspace.Workspace;
|
|||
import org.eclipse.che.api.core.model.workspace.WorkspaceConfig;
|
||||
import org.eclipse.che.api.core.model.workspace.WorkspaceStatus;
|
||||
import org.eclipse.che.api.machine.server.exception.SnapshotException;
|
||||
import org.eclipse.che.api.machine.server.model.impl.MachineSourceImpl;
|
||||
import org.eclipse.che.api.machine.server.model.impl.SnapshotImpl;
|
||||
import org.eclipse.che.api.machine.server.spi.SnapshotDao;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.MachineSourceImpl;
|
||||
import org.eclipse.che.commons.test.tck.TckListener;
|
||||
import org.eclipse.che.commons.test.tck.repository.TckRepository;
|
||||
import org.eclipse.che.commons.test.tck.repository.TckRepositoryException;
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.machine.server.jpa;
|
||||
package org.eclipse.che.workspace.infrastructure.docker.snapshot;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.Runtime;
|
||||
import org.eclipse.che.api.core.model.workspace.Workspace;
|
||||
|
|
@ -36,10 +36,6 @@
|
|||
<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-machine-shared</artifactId>
|
||||
|
|
|
|||
|
|
@ -10,31 +10,18 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.che.ide.ext.machine.server.ssh;
|
||||
|
||||
import org.eclipse.che.api.core.NotFoundException;
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.core.notification.EventService;
|
||||
import org.eclipse.che.api.core.notification.EventSubscriber;
|
||||
import org.eclipse.che.api.environment.server.CheEnvironmentEngine;
|
||||
import org.eclipse.che.api.machine.server.spi.Instance;
|
||||
import org.eclipse.che.api.machine.shared.dto.event.MachineStatusEvent;
|
||||
import org.eclipse.che.api.ssh.server.SshManager;
|
||||
import org.eclipse.che.api.ssh.server.model.impl.SshPairImpl;
|
||||
import org.eclipse.che.plugin.docker.client.DockerConnector;
|
||||
import org.eclipse.che.plugin.docker.client.DockerConnectorProvider;
|
||||
import org.eclipse.che.plugin.docker.client.Exec;
|
||||
import org.eclipse.che.plugin.docker.client.LogMessage;
|
||||
import org.eclipse.che.plugin.docker.client.params.CreateExecParams;
|
||||
import org.eclipse.che.plugin.docker.client.params.StartExecParams;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Injects public parts of ssh keys in the machine after container start
|
||||
|
|
@ -49,17 +36,18 @@ public class KeysInjector {
|
|||
private final DockerConnector docker;
|
||||
private final SshManager sshManager;
|
||||
// TODO replace with WorkspaceManager
|
||||
private final CheEnvironmentEngine environmentEngine;
|
||||
// private final CheEnvironmentEngine environmentEngine;
|
||||
|
||||
@Inject
|
||||
public KeysInjector(EventService eventService,
|
||||
DockerConnectorProvider provider,
|
||||
SshManager sshManager,
|
||||
CheEnvironmentEngine environmentEngine) {
|
||||
SshManager sshManager
|
||||
// CheEnvironmentEngine environmentEngine
|
||||
) {
|
||||
this.eventService = eventService;
|
||||
this.docker = provider.get();
|
||||
this.sshManager = sshManager;
|
||||
this.environmentEngine = environmentEngine;
|
||||
// this.environmentEngine = environmentEngine;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
|
|
@ -68,16 +56,16 @@ public class KeysInjector {
|
|||
@Override
|
||||
public void onEvent(MachineStatusEvent event) {
|
||||
if (event.getEventType() == MachineStatusEvent.EventType.RUNNING) {
|
||||
final Instance machine;
|
||||
/*final Instance machine;
|
||||
try {
|
||||
machine = environmentEngine.getMachine(event.getWorkspaceId(),
|
||||
event.getMachineId());
|
||||
} catch (NotFoundException e) {
|
||||
LOG.error("Unable to find machine: " + e.getLocalizedMessage(), e);
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
try {
|
||||
/*try {
|
||||
// get machine keypairs
|
||||
List<SshPairImpl> sshPairs = sshManager.getPairs(machine.getOwner(), "machine");
|
||||
final List<String> publicMachineKeys = sshPairs.stream()
|
||||
|
|
@ -130,7 +118,7 @@ public class KeysInjector {
|
|||
});
|
||||
} catch (IOException | ServerException e) {
|
||||
LOG.error(e.getLocalizedMessage(), e);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -11,13 +11,10 @@
|
|||
package org.eclipse.che.ide.ext.machine.server.ssh;
|
||||
|
||||
import org.eclipse.che.api.core.NotFoundException;
|
||||
import org.eclipse.che.api.core.model.machine.MachineRuntimeInfo;
|
||||
import org.eclipse.che.api.core.model.user.User;
|
||||
import org.eclipse.che.api.core.notification.EventService;
|
||||
import org.eclipse.che.api.core.notification.EventSubscriber;
|
||||
import org.eclipse.che.api.core.util.LineConsumer;
|
||||
import org.eclipse.che.api.environment.server.CheEnvironmentEngine;
|
||||
import org.eclipse.che.api.machine.server.spi.Instance;
|
||||
import org.eclipse.che.api.machine.shared.dto.event.MachineStatusEvent;
|
||||
import org.eclipse.che.api.ssh.server.SshManager;
|
||||
import org.eclipse.che.api.ssh.server.model.impl.SshPairImpl;
|
||||
|
|
@ -30,7 +27,6 @@ import org.eclipse.che.plugin.docker.client.params.CreateExecParams;
|
|||
import org.eclipse.che.plugin.docker.client.params.StartExecParams;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.testng.MockitoTestNGListener;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
|
|
|
|||
|
|
@ -66,10 +66,6 @@
|
|||
<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>
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@ import org.eclipse.che.api.core.model.machine.ServerConf;
|
|||
import org.eclipse.che.api.core.util.LineConsumer;
|
||||
import org.eclipse.che.api.machine.server.exception.MachineException;
|
||||
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.spi.InstanceNode;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.ServerImpl;
|
||||
|
||||
import javax.ws.rs.core.UriBuilder;
|
||||
import java.io.IOException;
|
||||
|
|
@ -154,9 +153,9 @@ public class SshMachineInstance {
|
|||
sshClient.stop();
|
||||
}
|
||||
|
||||
public InstanceNode getNode() {
|
||||
return null;// todo
|
||||
}
|
||||
// public InstanceNode getNode() {
|
||||
// return null;// todo
|
||||
// }
|
||||
|
||||
public MachineStatus getStatus() {
|
||||
return status;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import org.eclipse.che.api.core.util.LineConsumer;
|
|||
import org.eclipse.che.api.machine.server.exception.InvalidRecipeException;
|
||||
import org.eclipse.che.api.machine.server.exception.MachineException;
|
||||
import org.eclipse.che.api.machine.server.exception.UnsupportedRecipeException;
|
||||
import org.eclipse.che.api.machine.server.util.RecipeDownloader;
|
||||
import org.eclipse.che.api.workspace.server.RecipeDownloader;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
|
|
|
|||
|
|
@ -17,12 +17,11 @@ 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.ConflictException;
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.core.model.machine.Command;
|
||||
import org.eclipse.che.api.core.model.workspace.config.Command;
|
||||
import org.eclipse.che.api.core.util.AbstractLineConsumer;
|
||||
import org.eclipse.che.api.core.util.LineConsumer;
|
||||
import org.eclipse.che.api.core.util.ListLineConsumer;
|
||||
import org.eclipse.che.api.machine.server.exception.MachineException;
|
||||
import org.eclipse.che.api.machine.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.commons.lang.concurrent.LoggingUncaughtExceptionHandler;
|
||||
import org.eclipse.che.commons.lang.concurrent.ThreadLocalPropagateContext;
|
||||
import org.eclipse.che.plugin.machine.ssh.SshMachineInstance;
|
||||
|
|
@ -111,7 +110,7 @@ public class SshMachineExecAgentLauncher {
|
|||
final String errMsg = format("Fail launching agent %s. Workspace ID:%s", agent.getName(), machine.getWorkspaceId());
|
||||
LOG.error(errMsg);
|
||||
throw new ServerException(errMsg);
|
||||
} catch (MachineException e) {
|
||||
} catch (ServerException e) {
|
||||
throw new ServerException(e.getServiceError());
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
|
|
@ -122,7 +121,7 @@ public class SshMachineExecAgentLauncher {
|
|||
}
|
||||
}
|
||||
|
||||
private String detectArchitecture(SshMachineInstance machine) throws ConflictException, MachineException {
|
||||
private String detectArchitecture(SshMachineInstance machine) throws ConflictException, ServerException {
|
||||
// uname -sm shows OS and CPU architecture
|
||||
// Examples of output:
|
||||
// Windows 10 amd64
|
||||
|
|
@ -191,7 +190,7 @@ public class SshMachineExecAgentLauncher {
|
|||
try {
|
||||
countDownLatch.countDown();
|
||||
process.start(lineConsumer);
|
||||
} catch (ConflictException | MachineException e) {
|
||||
} catch (ConflictException e) {
|
||||
try {
|
||||
machine.getLogger().writeLine(format("[ERROR] %s", e.getMessage()));
|
||||
} catch (IOException ignored) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import org.eclipse.che.api.core.ConflictException;
|
|||
import org.eclipse.che.api.core.model.machine.Command;
|
||||
import org.eclipse.che.api.core.util.ListLineConsumer;
|
||||
import org.eclipse.che.api.machine.server.exception.MachineException;
|
||||
import org.eclipse.che.api.machine.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.plugin.machine.ssh.SshMachineInstance;
|
||||
import org.eclipse.che.plugin.machine.ssh.SshMachineProcess;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,11 +18,11 @@ import org.eclipse.che.api.core.model.machine.MachineStatus;
|
|||
import org.eclipse.che.api.core.util.LineConsumer;
|
||||
import org.eclipse.che.api.machine.server.exception.MachineException;
|
||||
import org.eclipse.che.api.machine.server.model.impl.MachineConfigImpl;
|
||||
import org.eclipse.che.api.machine.server.model.impl.MachineImpl;
|
||||
import org.eclipse.che.api.machine.server.model.impl.MachineSourceImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.MachineImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.MachineSourceImpl;
|
||||
import org.eclipse.che.api.machine.server.model.impl.ServerConfImpl;
|
||||
import org.eclipse.che.api.machine.server.recipe.RecipeImpl;
|
||||
import org.eclipse.che.api.machine.server.util.RecipeDownloader;
|
||||
import org.eclipse.che.api.workspace.server.RecipeDownloader;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.testng.MockitoTestNGListener;
|
||||
|
|
|
|||
11
pom.xml
11
pom.xml
|
|
@ -273,17 +273,6 @@
|
|||
<artifactId>che-core-api-languageserver-shared</artifactId>
|
||||
<version>${che.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-machine</artifactId>
|
||||
<version>${che.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-machine</artifactId>
|
||||
<version>${che.version}</version>
|
||||
<classifier>tests</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-machine-shared</artifactId>
|
||||
|
|
|
|||
|
|
@ -45,10 +45,6 @@
|
|||
<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>
|
||||
|
|
|
|||
|
|
@ -112,11 +112,6 @@
|
|||
<artifactId>javax.ws.rs-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-machine</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-machine-shared</artifactId>
|
||||
|
|
|
|||
|
|
@ -13,20 +13,15 @@ package org.eclipse.che.api.factory.server.jpa;
|
|||
import com.google.inject.TypeLiteral;
|
||||
|
||||
import org.eclipse.che.account.spi.AccountImpl;
|
||||
import org.eclipse.che.api.factory.server.FactoryImage;
|
||||
import org.eclipse.che.api.factory.server.model.impl.ActionImpl;
|
||||
import org.eclipse.che.api.factory.server.model.impl.AuthorImpl;
|
||||
import org.eclipse.che.api.factory.server.model.impl.ButtonAttributesImpl;
|
||||
import org.eclipse.che.api.factory.server.model.impl.ButtonImpl;
|
||||
import org.eclipse.che.api.factory.server.model.impl.FactoryImpl;
|
||||
import org.eclipse.che.api.factory.server.model.impl.IdeImpl;
|
||||
import org.eclipse.che.api.factory.server.model.impl.OnAppClosedImpl;
|
||||
import org.eclipse.che.api.factory.server.model.impl.OnAppLoadedImpl;
|
||||
import org.eclipse.che.api.factory.server.model.impl.OnProjectsLoadedImpl;
|
||||
import org.eclipse.che.api.factory.server.model.impl.PoliciesImpl;
|
||||
import org.eclipse.che.api.factory.server.spi.FactoryDao;
|
||||
import org.eclipse.che.api.machine.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.api.machine.server.model.impl.MachineSourceImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.api.user.server.model.impl.UserImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import org.eclipse.che.api.factory.server.model.impl.OnAppLoadedImpl;
|
|||
import org.eclipse.che.api.factory.server.model.impl.OnProjectsLoadedImpl;
|
||||
import org.eclipse.che.api.factory.server.model.impl.PoliciesImpl;
|
||||
import org.eclipse.che.api.factory.server.spi.FactoryDao;
|
||||
import org.eclipse.che.api.machine.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.CommandImpl;
|
||||
import org.eclipse.che.api.user.server.model.impl.UserImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.EnvironmentImpl;
|
||||
import org.eclipse.che.api.workspace.server.model.impl.EnvironmentRecipeImpl;
|
||||
|
|
|
|||
|
|
@ -1,225 +0,0 @@
|
|||
<?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-master-parent</artifactId>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<version>5.9.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>che-core-api-machine</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Che Core :: API :: Machine</name>
|
||||
<properties>
|
||||
<findbugs.failonerror>false</findbugs.failonerror>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.inject</groupId>
|
||||
<artifactId>guice</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>javax.ws.rs-api</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-dto</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-machine-shared</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-commons-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-commons-lang</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.everrest</groupId>
|
||||
<artifactId>everrest-websockets</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.inject.extensions</groupId>
|
||||
<artifactId>guice-persist</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.websocket</groupId>
|
||||
<artifactId>javax.websocket-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-db</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.persistence</groupId>
|
||||
<artifactId>javax.persistence</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Test dependencies -->
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-account</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-user</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-commons-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-db-vendor-h2</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-sql-schema</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.persistence</groupId>
|
||||
<artifactId>eclipselink</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.everrest</groupId>
|
||||
<artifactId>everrest-assured</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.everrest</groupId>
|
||||
<artifactId>everrest-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.everrest</groupId>
|
||||
<artifactId>everrest-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-core</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.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/spi/tck/*.*</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
@ -1,168 +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.machine.server;
|
||||
|
||||
import org.eclipse.che.api.core.model.machine.OldMachine;
|
||||
import org.eclipse.che.api.core.model.machine.OldMachineConfig;
|
||||
import org.eclipse.che.api.core.model.machine.MachineLimits;
|
||||
import org.eclipse.che.api.core.model.machine.MachineProcess;
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.api.core.model.machine.MachineSource;
|
||||
import org.eclipse.che.api.core.model.machine.OldServer;
|
||||
import org.eclipse.che.api.core.model.machine.OldServerConf;
|
||||
import org.eclipse.che.api.core.model.machine.ServerProperties;
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Server;
|
||||
import org.eclipse.che.api.core.model.machine.Snapshot;
|
||||
import org.eclipse.che.api.machine.shared.dto.MachineDto;
|
||||
import org.eclipse.che.api.machine.shared.dto.OldMachineConfigDto;
|
||||
import org.eclipse.che.api.machine.shared.dto.OldMachineDto;
|
||||
import org.eclipse.che.api.machine.shared.dto.MachineLimitsDto;
|
||||
import org.eclipse.che.api.machine.shared.dto.MachineProcessDto;
|
||||
import org.eclipse.che.api.machine.shared.dto.MachineSourceDto;
|
||||
import org.eclipse.che.api.machine.shared.dto.OldServerDto;
|
||||
import org.eclipse.che.api.machine.shared.dto.OldServerConfDto;
|
||||
import org.eclipse.che.api.machine.shared.dto.ServerPropertiesDto;
|
||||
import org.eclipse.che.api.machine.shared.dto.ServerDto;
|
||||
import org.eclipse.che.api.machine.shared.dto.SnapshotDto;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.stream.Collectors.toMap;
|
||||
import static org.eclipse.che.dto.server.DtoFactory.newDto;
|
||||
|
||||
/**
|
||||
* Helps to convert to/from DTOs related to workspace.
|
||||
*
|
||||
* @author Yevhenii Voevodin
|
||||
*/
|
||||
public final class DtoConverter {
|
||||
/**
|
||||
* Converts {@link OldMachineConfig} to {@link OldMachineConfigDto}.
|
||||
*/
|
||||
public static OldMachineConfigDto asDto(OldMachineConfig config) {
|
||||
return newDto(OldMachineConfigDto.class).withName(config.getName())
|
||||
.withType(config.getType())
|
||||
.withDev(config.isDev())
|
||||
.withLimits(config.getLimits() == null ? null : asDto(config.getLimits()))
|
||||
.withSource(config.getSource() == null ? null : asDto(config.getSource()))
|
||||
.withServers(config.getServers()
|
||||
.stream()
|
||||
.map(DtoConverter::asDto)
|
||||
.collect(Collectors.toList()))
|
||||
.withEnvVariables(config.getEnvVariables());
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts {@link MachineSource} to {@link MachineSourceDto}.
|
||||
*/
|
||||
public static MachineSourceDto asDto(MachineSource source) {
|
||||
return newDto(MachineSourceDto.class).withType(source.getType()).withLocation(source.getLocation()).withContent(source.getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts {@link MachineLimits} to {@link MachineLimitsDto}.
|
||||
*/
|
||||
public static MachineLimitsDto asDto(MachineLimits machineLimits) {
|
||||
return newDto(MachineLimitsDto.class).withRam(machineLimits.getRam());
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts {@link OldMachine} to {@link OldMachineDto}.
|
||||
*/
|
||||
public static OldMachineDto asDto(OldMachine machine) {
|
||||
final OldMachineDto machineDto = newDto(OldMachineDto.class).withConfig(asDto(machine.getConfig()))
|
||||
.withId(machine.getId())
|
||||
.withStatus(machine.getStatus())
|
||||
.withOwner(machine.getOwner())
|
||||
.withEnvName(machine.getEnvName())
|
||||
.withWorkspaceId(machine.getWorkspaceId());
|
||||
if (machine.getRuntime() != null) {
|
||||
machineDto.withRuntime(asDto(machine.getRuntime()));
|
||||
}
|
||||
return machineDto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts {@link Machine} to {@link MachineDto}.
|
||||
*/
|
||||
private static MachineDto asDto(Machine runtime) {
|
||||
final Map<String, ServerDto>servers = runtime.getServers()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.collect(toMap(Map.Entry::getKey, entry -> asDto(entry.getValue())));
|
||||
|
||||
return newDto(MachineDto.class)//.withEnvVariables(runtime.getEnvVariables())
|
||||
.withProperties(runtime.getProperties())
|
||||
.withServers(servers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts {@link OldServer} to {@link OldServerDto}.
|
||||
*/
|
||||
public static ServerDto asDto(Server server) {
|
||||
return newDto(ServerDto.class).withUrl(server.getUrl());
|
||||
// .withAddress(server.getAddress())
|
||||
// .withRef(server.getRef())
|
||||
// .withProtocol(server.getProtocol())
|
||||
// .withUrl(server.getUrl())
|
||||
// .withProperties(server.getProperties() == null ? null : asDto(server.getProperties()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts {@link ServerProperties} to {@link ServerPropertiesDto}.
|
||||
*/
|
||||
public static ServerPropertiesDto asDto(ServerProperties serverProperties) {
|
||||
return newDto(ServerPropertiesDto.class).withPath(serverProperties.getPath())
|
||||
.withInternalAddress(serverProperties.getInternalAddress())
|
||||
.withInternalUrl(serverProperties.getInternalUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts {@link OldServerConf} to {@link OldServerConfDto}.
|
||||
*/
|
||||
public static OldServerConfDto asDto(OldServerConf serverConf) {
|
||||
return newDto(OldServerConfDto.class).withRef(serverConf.getRef())
|
||||
.withPort(serverConf.getPort())
|
||||
.withProtocol(serverConf.getProtocol())
|
||||
.withPath(serverConf.getPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts {@link Snapshot} to {@link SnapshotDto}.
|
||||
*/
|
||||
public static SnapshotDto asDto(Snapshot snapshot) {
|
||||
return newDto(SnapshotDto.class).withType(snapshot.getType())
|
||||
.withDescription(snapshot.getDescription())
|
||||
.withCreationDate(snapshot.getCreationDate())
|
||||
.withDev(snapshot.isDev())
|
||||
.withId(snapshot.getId())
|
||||
.withWorkspaceId(snapshot.getWorkspaceId())
|
||||
.withLinks(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts {@link MachineProcess} to {@link MachineProcessDto}.
|
||||
*/
|
||||
public static MachineProcessDto asDto(MachineProcess machineProcess) {
|
||||
return newDto(MachineProcessDto.class).withPid(machineProcess.getPid())
|
||||
.withCommandLine(machineProcess.getCommandLine())
|
||||
.withAlive(machineProcess.isAlive())
|
||||
.withName(machineProcess.getName())
|
||||
.withAttributes(machineProcess.getAttributes())
|
||||
.withType(machineProcess.getType())
|
||||
.withOutputChannel(machineProcess.getOutputChannel())
|
||||
.withLinks(null);
|
||||
}
|
||||
|
||||
private DtoConverter() {
|
||||
}
|
||||
}
|
||||
|
|
@ -1,74 +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.machine.server;
|
||||
|
||||
import org.eclipse.che.api.core.NotFoundException;
|
||||
import org.eclipse.che.api.machine.server.spi.InstanceProvider;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Provides machines {@link InstanceProvider} implementation by machine type
|
||||
*
|
||||
* @author Alexander Garagatyi
|
||||
*/
|
||||
@Singleton
|
||||
public class MachineInstanceProviders {
|
||||
private final Map<String, InstanceProvider> instanceProviders;
|
||||
|
||||
@Inject
|
||||
public MachineInstanceProviders(Set<InstanceProvider> instanceProviders) {
|
||||
this.instanceProviders = new HashMap<>(instanceProviders.size());
|
||||
for (InstanceProvider provider : instanceProviders) {
|
||||
this.instanceProviders.put(provider.getType(), provider);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link InstanceProvider} implementation by machine type
|
||||
*
|
||||
* @param machineType type of machine implementation
|
||||
* @return implementation of the machine {code InstanceProvider}
|
||||
* @throws NotFoundException if no implementation found for provided machine type
|
||||
*/
|
||||
public InstanceProvider getProvider(String machineType) throws NotFoundException {
|
||||
if (hasProvider(machineType)) {
|
||||
return instanceProviders.get(machineType);
|
||||
}
|
||||
throw new NotFoundException(String.format("Can't find machine provider for unsupported machine type '%s'", machineType));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an {@link InstanceProvider} implementation of the given machine type exists
|
||||
*
|
||||
* @param machineType type of machine implementation
|
||||
* @return <code>true</code> if such implementation exists, <code>false</code> otherwise
|
||||
*/
|
||||
public boolean hasProvider(String machineType) {
|
||||
return instanceProviders.containsKey(machineType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the machine types of all available {@link InstanceProvider} implementations.
|
||||
*
|
||||
* @return a collection of machine types
|
||||
*/
|
||||
public Collection<String> getProviderTypes() {
|
||||
return Collections.unmodifiableSet(instanceProviders.keySet());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +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.machine.server;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
import org.eclipse.che.api.machine.server.event.MachineProcessMessenger;
|
||||
import org.eclipse.che.api.machine.server.event.MachineStateJsonRpcMessenger;
|
||||
import org.eclipse.che.api.machine.server.event.MachineStateMessenger;
|
||||
import org.eclipse.che.api.machine.shared.Constants;
|
||||
|
||||
/**
|
||||
* Guice container configuration file. Replaces old REST application composers and servlet context listeners.
|
||||
*
|
||||
* @author Alexander Garagatyi
|
||||
*/
|
||||
public class MachineModule extends AbstractModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(MachineStateMessenger.class).asEagerSingleton();
|
||||
bind(MachineStateJsonRpcMessenger.class).asEagerSingleton();
|
||||
bind(MachineProcessMessenger.class).asEagerSingleton();
|
||||
|
||||
bindConstant().annotatedWith(Names.named("machine.extension.api_port")).to(Constants.WS_AGENT_PORT);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,51 +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.machine.server.event;
|
||||
|
||||
/**
|
||||
* Describe instance state change.
|
||||
*
|
||||
* @author Alexander Garagatyi
|
||||
*/
|
||||
public class InstanceStateEvent {
|
||||
/**
|
||||
* Type of state change of a machine instance.<br>
|
||||
* Consider that machine implementation may or may not support each state change type.
|
||||
*/
|
||||
public enum Type {
|
||||
DIE,
|
||||
OOM
|
||||
}
|
||||
|
||||
private String machineId;
|
||||
private String workspaceId;
|
||||
private Type type;
|
||||
|
||||
public InstanceStateEvent(String machineId,
|
||||
String workspaceId,
|
||||
Type type) {
|
||||
this.machineId = machineId;
|
||||
this.workspaceId = workspaceId;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getMachineId() {
|
||||
return machineId;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getWorkspaceId() {
|
||||
return workspaceId;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,64 +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.machine.server.event;
|
||||
|
||||
import org.eclipse.che.api.core.notification.EventService;
|
||||
import org.eclipse.che.api.core.notification.EventSubscriber;
|
||||
import org.eclipse.che.api.machine.shared.dto.event.MachineProcessEvent;
|
||||
import org.eclipse.che.dto.server.DtoFactory;
|
||||
import org.everrest.websockets.WSConnectionContext;
|
||||
import org.everrest.websockets.message.ChannelBroadcastMessage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
/**
|
||||
* Send machine process events using websocket channel to the clients
|
||||
*
|
||||
* @author Alexander Garagatyi
|
||||
*/
|
||||
@Singleton // should be eager
|
||||
public class MachineProcessMessenger implements EventSubscriber<MachineProcessEvent> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MachineProcessMessenger.class);
|
||||
|
||||
private final EventService eventService;
|
||||
|
||||
@Inject
|
||||
public MachineProcessMessenger(EventService eventService) {
|
||||
this.eventService = eventService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(MachineProcessEvent event) {
|
||||
try {
|
||||
final ChannelBroadcastMessage bm = new ChannelBroadcastMessage();
|
||||
bm.setChannel("machine:process:" + event.getMachineId());
|
||||
bm.setBody(DtoFactory.getInstance().toJson(event));
|
||||
WSConnectionContext.sendMessage(bm);
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
private void subscribe() {
|
||||
eventService.subscribe(this);
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
private void unsubscribe() {
|
||||
eventService.unsubscribe(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,95 +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.machine.server.event;
|
||||
|
||||
import org.eclipse.che.api.core.jsonrpc.RequestHandlerConfigurator;
|
||||
import org.eclipse.che.api.core.jsonrpc.RequestTransmitter;
|
||||
import org.eclipse.che.api.core.notification.EventService;
|
||||
import org.eclipse.che.api.core.notification.EventSubscriber;
|
||||
import org.eclipse.che.api.machine.shared.dto.event.MachineProcessEvent;
|
||||
import org.eclipse.che.api.machine.shared.dto.event.MachineStatusEvent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static com.google.common.collect.Sets.newConcurrentHashSet;
|
||||
|
||||
@Singleton
|
||||
public class MachineStateJsonRpcMessenger implements EventSubscriber<MachineStatusEvent> {
|
||||
private final RequestTransmitter transmitter;
|
||||
private final EventService eventService;
|
||||
|
||||
private final Map<String, Set<String>> endpointIds = new ConcurrentHashMap<>();
|
||||
|
||||
@Inject
|
||||
public MachineStateJsonRpcMessenger(RequestTransmitter transmitter, EventService eventService) {
|
||||
this.transmitter = transmitter;
|
||||
this.eventService = eventService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(MachineStatusEvent event) {
|
||||
String id = event.getWorkspaceId();
|
||||
endpointIds.entrySet()
|
||||
.stream()
|
||||
.filter(it -> it.getValue().contains(id))
|
||||
.map(Map.Entry::getKey)
|
||||
.forEach(it -> transmitter.transmitOneToNone(it, "event:environment-status:changed", event));
|
||||
}
|
||||
|
||||
@Inject
|
||||
private void configureSubscribeHandler(RequestHandlerConfigurator configurator) {
|
||||
|
||||
configurator.newConfiguration()
|
||||
.methodName("event:environment-status:subscribe")
|
||||
.paramsAsString()
|
||||
.noResult()
|
||||
.withConsumer((endpointId, workspaceId) -> {
|
||||
endpointIds.putIfAbsent(endpointId, newConcurrentHashSet());
|
||||
endpointIds.get(endpointId).add(workspaceId);
|
||||
});
|
||||
}
|
||||
|
||||
@Inject
|
||||
private void configureUnSubscribeHandler(RequestHandlerConfigurator configurator) {
|
||||
configurator.newConfiguration()
|
||||
.methodName("event:environment-status:un-subscribe")
|
||||
.paramsAsString()
|
||||
.noResult()
|
||||
.withConsumer((endpointId, workspaceId) -> {
|
||||
Set<String> workspaceIds = endpointIds.get(endpointId);
|
||||
if (workspaceIds != null) {
|
||||
workspaceIds.remove(workspaceId);
|
||||
|
||||
if (workspaceIds.isEmpty()) {
|
||||
endpointIds.remove(endpointId);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
private void subscribe() {
|
||||
eventService.subscribe(this);
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
private void unsubscribe() {
|
||||
eventService.unsubscribe(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,67 +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.machine.server.event;
|
||||
|
||||
import org.eclipse.che.api.core.notification.EventService;
|
||||
import org.eclipse.che.api.core.notification.EventSubscriber;
|
||||
import org.eclipse.che.api.machine.shared.dto.event.MachineStatusEvent;
|
||||
import org.eclipse.che.dto.server.DtoFactory;
|
||||
import org.everrest.websockets.WSConnectionContext;
|
||||
import org.everrest.websockets.message.ChannelBroadcastMessage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import static java.lang.String.format;
|
||||
import static org.eclipse.che.api.machine.shared.Constants.ENVIRONMENT_STATUS_CHANNEL_TEMPLATE;
|
||||
|
||||
/**
|
||||
* Send machine state events using websocket channel to the clients
|
||||
*
|
||||
* @author Alexander Garagatyi
|
||||
*/
|
||||
@Singleton // should be eager
|
||||
public class MachineStateMessenger implements EventSubscriber<MachineStatusEvent> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MachineStateMessenger.class);
|
||||
|
||||
private final EventService eventService;
|
||||
|
||||
@Inject
|
||||
public MachineStateMessenger(EventService eventService) {
|
||||
this.eventService = eventService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(MachineStatusEvent event) {
|
||||
try {
|
||||
final ChannelBroadcastMessage bm = new ChannelBroadcastMessage();
|
||||
bm.setChannel(format(ENVIRONMENT_STATUS_CHANNEL_TEMPLATE, event.getWorkspaceId()));
|
||||
bm.setBody(DtoFactory.getInstance().toJson(event));
|
||||
WSConnectionContext.sendMessage(bm);
|
||||
} catch (Exception e) {
|
||||
LOG.error(e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
private void subscribe() {
|
||||
eventService.subscribe(this);
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
private void unsubscribe() {
|
||||
eventService.unsubscribe(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +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.machine.server.exception;
|
||||
|
||||
/**
|
||||
* @author gazarenkov
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class InvalidInstanceSnapshotException extends MachineException {
|
||||
public InvalidInstanceSnapshotException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +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.machine.server.exception;
|
||||
|
||||
/**
|
||||
* @author gazarenkov
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class InvalidRecipeException extends MachineException {
|
||||
public InvalidRecipeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +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.machine.server.exception;
|
||||
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.core.rest.shared.dto.ServiceError;
|
||||
|
||||
/**
|
||||
* @author andrew00x
|
||||
* @author Alexander Garagatyi
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class MachineException extends ServerException {
|
||||
public MachineException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public MachineException(ServiceError serviceError) {
|
||||
super(serviceError);
|
||||
}
|
||||
|
||||
public MachineException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public MachineException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +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.machine.server.exception;
|
||||
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.core.rest.shared.dto.ServiceError;
|
||||
|
||||
/**
|
||||
* @author Alexander Garagatyi
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class SnapshotException extends ServerException {
|
||||
public SnapshotException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public SnapshotException(ServiceError serviceError) {
|
||||
super(serviceError);
|
||||
}
|
||||
|
||||
public SnapshotException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public SnapshotException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +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.machine.server.exception;
|
||||
|
||||
import org.eclipse.che.api.core.rest.shared.dto.ServiceError;
|
||||
|
||||
/**
|
||||
* Occurs when machine sources is not found or is not available.
|
||||
*
|
||||
* @author Anton Korneta
|
||||
*/
|
||||
public class SourceNotFoundException extends MachineException {
|
||||
public SourceNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public SourceNotFoundException(ServiceError serviceError) {
|
||||
super(serviceError);
|
||||
}
|
||||
|
||||
public SourceNotFoundException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public SourceNotFoundException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +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.machine.server.exception;
|
||||
|
||||
import org.eclipse.che.api.core.NotFoundException;
|
||||
|
||||
/**
|
||||
* @author gazarenkov
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class UnsupportedRecipeException extends NotFoundException {
|
||||
public UnsupportedRecipeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +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.machine.server.jpa;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
|
||||
import org.eclipse.che.api.machine.server.spi.RecipeDao;
|
||||
import org.eclipse.che.api.machine.server.spi.SnapshotDao;
|
||||
|
||||
/**
|
||||
* @author Yevhenii Voevodin
|
||||
*/
|
||||
public class MachineJpaModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(RecipeDao.class).to(JpaRecipeDao.class);
|
||||
bind(SnapshotDao.class).to(JpaSnapshotDao.class);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,68 +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.machine.server.model.impl;
|
||||
|
||||
import org.eclipse.che.api.core.model.machine.MachineLimits;
|
||||
|
||||
/**
|
||||
* @author Alexander Garagatyi
|
||||
* @author Yevhenii Voevodin
|
||||
*/
|
||||
public class MachineLimitsImpl implements MachineLimits {
|
||||
|
||||
private int memory;
|
||||
|
||||
public MachineLimitsImpl(MachineLimits machineLimits) {
|
||||
if (machineLimits != null) {
|
||||
memory = machineLimits.getRam();
|
||||
} else {
|
||||
memory = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public MachineLimitsImpl() {}
|
||||
|
||||
public MachineLimitsImpl(int memory) {
|
||||
this.memory = memory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRam() {
|
||||
return memory;
|
||||
}
|
||||
|
||||
public void setRam(int memory) {
|
||||
this.memory = memory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof MachineLimitsImpl)) return false;
|
||||
|
||||
MachineLimitsImpl limits = (MachineLimitsImpl)o;
|
||||
|
||||
return memory == limits.memory;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return memory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MachineLimitsImpl{" +
|
||||
"memory=" + memory +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -1,69 +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.machine.server.model.impl;
|
||||
|
||||
import org.eclipse.che.api.core.model.machine.MachineLogMessage;
|
||||
import org.eclipse.che.api.machine.shared.dto.MachineLogMessageDto;
|
||||
import org.eclipse.che.dto.server.DtoFactory;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Alexander Garagatyi
|
||||
*/
|
||||
public class MachineLogMessageImpl implements MachineLogMessage {
|
||||
private String machineName;
|
||||
private String content;
|
||||
|
||||
public MachineLogMessageImpl() {}
|
||||
|
||||
public MachineLogMessageImpl(String machineName, String content) {
|
||||
this.machineName = machineName;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMachineName() {
|
||||
return machineName;
|
||||
}
|
||||
|
||||
public void setMachineName(String machine) {
|
||||
this.machineName = machine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof MachineLogMessageImpl)) return false;
|
||||
MachineLogMessageImpl that = (MachineLogMessageImpl)o;
|
||||
return Objects.equals(machineName, that.machineName) &&
|
||||
Objects.equals(content, that.content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(machineName, content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return DtoFactory.newDto(MachineLogMessageDto.class).withContent(content).withMachineName(machineName).toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,260 +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.machine.server.model.impl;
|
||||
|
||||
import org.eclipse.che.api.core.model.machine.OldMachineConfig;
|
||||
import org.eclipse.che.api.core.model.machine.MachineLimits;
|
||||
import org.eclipse.che.api.core.model.machine.MachineSource;
|
||||
import org.eclipse.che.api.core.model.machine.OldServerConf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Data object for {@link OldMachineConfig}.
|
||||
*
|
||||
* @author Eugene Voevodin
|
||||
*/
|
||||
public class OldMachineConfigImpl implements OldMachineConfig {
|
||||
|
||||
public static MachineConfigImplBuilder builder() {
|
||||
return new MachineConfigImplBuilder();
|
||||
}
|
||||
|
||||
private boolean dev;
|
||||
private String name;
|
||||
private String type;
|
||||
private MachineSourceImpl source;
|
||||
private MachineLimitsImpl limits;
|
||||
private List<OldServerConfImpl> servers;
|
||||
private Map<String, String> envVariables;
|
||||
|
||||
public OldMachineConfigImpl() {
|
||||
}
|
||||
|
||||
public OldMachineConfigImpl(boolean dev,
|
||||
String name,
|
||||
String type,
|
||||
MachineSource source,
|
||||
MachineLimits machineLimits,
|
||||
List<? extends OldServerConf> servers,
|
||||
Map<String, String> envVariables) {
|
||||
this.dev = dev;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.envVariables = envVariables;
|
||||
if (servers != null) {
|
||||
this.servers = servers.stream()
|
||||
.map(OldServerConfImpl::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
if (source != null) {
|
||||
this.source = new MachineSourceImpl(source);
|
||||
}
|
||||
this.limits = new MachineLimitsImpl(machineLimits);
|
||||
|
||||
}
|
||||
|
||||
public OldMachineConfigImpl(OldMachineConfig machineCfg) {
|
||||
this(machineCfg.isDev(),
|
||||
machineCfg.getName(),
|
||||
machineCfg.getType(),
|
||||
machineCfg.getSource(),
|
||||
machineCfg.getLimits(),
|
||||
machineCfg.getServers(),
|
||||
machineCfg.getEnvVariables());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MachineSourceImpl getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setSource(MachineSourceImpl machineSource) {
|
||||
this.source = machineSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDev() {
|
||||
return dev;
|
||||
}
|
||||
|
||||
public void setDev(boolean dev) {
|
||||
this.dev = dev;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MachineLimitsImpl getLimits() {
|
||||
return limits;
|
||||
}
|
||||
|
||||
public void setLimits(MachineLimits machineLimits) {
|
||||
this.limits = new MachineLimitsImpl(machineLimits);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OldServerConfImpl> getServers() {
|
||||
if (servers == null) {
|
||||
servers = new ArrayList<>();
|
||||
}
|
||||
return servers;
|
||||
}
|
||||
|
||||
public void setServers(List<OldServerConfImpl> servers) {
|
||||
this.servers = servers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getEnvVariables() {
|
||||
if (envVariables == null) {
|
||||
envVariables = new HashMap<>();
|
||||
}
|
||||
return envVariables;
|
||||
}
|
||||
|
||||
public void setEnvVariables(Map<String, String> envVariables) {
|
||||
this.envVariables = envVariables;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof OldMachineConfigImpl)) return false;
|
||||
final OldMachineConfigImpl other = (OldMachineConfigImpl)obj;
|
||||
return dev == other.dev &&
|
||||
Objects.equals(name, other.name) &&
|
||||
Objects.equals(source, other.source) &&
|
||||
Objects.equals(limits, other.limits) &&
|
||||
Objects.equals(type, other.type) &&
|
||||
Objects.equals(getServers(), other.getServers()) &&
|
||||
Objects.equals(getEnvVariables(), other.getEnvVariables());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = hash * 31 + Boolean.hashCode(dev);
|
||||
hash = hash * 31 + Objects.hashCode(name);
|
||||
hash = hash * 31 + Objects.hashCode(type);
|
||||
hash = hash * 31 + Objects.hashCode(source);
|
||||
hash = hash * 31 + Objects.hashCode(limits);
|
||||
hash = hash * 31 + Objects.hashCode(getServers());
|
||||
hash = hash * 31 + Objects.hashCode(getEnvVariables());
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OldMachineConfigImpl{" +
|
||||
"dev=" + dev +
|
||||
", name='" + name + '\'' +
|
||||
", type='" + type + '\'' +
|
||||
", source=" + source +
|
||||
", machineLimits=" + limits +
|
||||
", servers=" + getServers() +
|
||||
", envVariables=" + getEnvVariables() +
|
||||
'}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Helps to build complex {@link OldMachineConfigImpl machine config impl}.
|
||||
*
|
||||
* @see OldMachineConfigImpl#builder()
|
||||
*/
|
||||
public static class MachineConfigImplBuilder {
|
||||
|
||||
private boolean dev;
|
||||
private String name;
|
||||
private String type;
|
||||
private MachineSource source;
|
||||
private MachineLimits machineLimits;
|
||||
private List<? extends OldServerConf> servers;
|
||||
private Map<String, String> envVariables;
|
||||
|
||||
public OldMachineConfigImpl build() {
|
||||
return new OldMachineConfigImpl(dev,
|
||||
name,
|
||||
type,
|
||||
source,
|
||||
machineLimits,
|
||||
servers,
|
||||
envVariables);
|
||||
}
|
||||
|
||||
public MachineConfigImplBuilder fromConfig(OldMachineConfig machineConfig) {
|
||||
dev = machineConfig.isDev();
|
||||
name = machineConfig.getName();
|
||||
type = machineConfig.getType();
|
||||
source = machineConfig.getSource();
|
||||
machineLimits = machineConfig.getLimits();
|
||||
servers = machineConfig.getServers();
|
||||
envVariables = machineConfig.getEnvVariables();
|
||||
return this;
|
||||
}
|
||||
|
||||
public MachineConfigImplBuilder setDev(boolean dev) {
|
||||
this.dev = dev;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MachineConfigImplBuilder setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MachineConfigImplBuilder setType(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MachineConfigImplBuilder setSource(MachineSource machineSource) {
|
||||
this.source = machineSource;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MachineConfigImplBuilder setLimits(MachineLimits machineLimits) {
|
||||
this.machineLimits = machineLimits;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MachineConfigImplBuilder setServers(List<? extends OldServerConf> servers) {
|
||||
this.servers = servers;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MachineConfigImplBuilder setEnvVariables(Map<String, String> envVariables) {
|
||||
this.envVariables = envVariables;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,200 +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.machine.server.model.impl;
|
||||
|
||||
import org.eclipse.che.api.core.model.machine.OldMachine;
|
||||
import org.eclipse.che.api.core.model.machine.OldMachineConfig;
|
||||
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
|
||||
import org.eclipse.che.api.core.model.machine.MachineStatus;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Data object for {@link OldMachine}.
|
||||
*
|
||||
* @author Eugene Voevodin
|
||||
* @author Alexander Garagatyi
|
||||
*/
|
||||
public class OldMachineImpl implements OldMachine {
|
||||
|
||||
public static MachineImplBuilder builder() {
|
||||
return new MachineImplBuilder();
|
||||
}
|
||||
|
||||
private final OldMachineConfigImpl machineConfig;
|
||||
private final MachineImpl machineRuntime;
|
||||
private final String workspace;
|
||||
private final String envName;
|
||||
private final String owner;
|
||||
|
||||
private MachineStatus status;
|
||||
private String id;
|
||||
|
||||
public OldMachineImpl(OldMachineConfig machineConfig,
|
||||
String id,
|
||||
String workspace,
|
||||
String envName,
|
||||
String owner,
|
||||
MachineStatus status,
|
||||
Machine machine) {
|
||||
this.workspace = workspace;
|
||||
this.envName = envName;
|
||||
this.owner = owner;
|
||||
this.machineConfig = new OldMachineConfigImpl(machineConfig);
|
||||
this.id = id;
|
||||
this.status = status;
|
||||
this.machineRuntime = machine != null ? new MachineImpl(machine.getProperties(), machine.getServers()) : null;
|
||||
}
|
||||
|
||||
public OldMachineImpl(OldMachine machine) {
|
||||
this(machine.getConfig(),
|
||||
machine.getId(),
|
||||
machine.getWorkspaceId(),
|
||||
machine.getEnvName(),
|
||||
machine.getOwner(),
|
||||
machine.getStatus(),
|
||||
machine.getRuntime());
|
||||
}
|
||||
|
||||
@Override
|
||||
public OldMachineConfigImpl getConfig() {
|
||||
return machineConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorkspaceId() {
|
||||
return workspace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEnvName() {
|
||||
return envName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MachineStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MachineImpl getRuntime() {
|
||||
return machineRuntime;
|
||||
}
|
||||
|
||||
public void setStatus(MachineStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof OldMachineImpl)) return false;
|
||||
OldMachineImpl machine = (OldMachineImpl)o;
|
||||
return Objects.equals(machineConfig, machine.machineConfig) &&
|
||||
Objects.equals(id, machine.id) &&
|
||||
Objects.equals(machineRuntime, machine.machineRuntime) &&
|
||||
Objects.equals(workspace, machine.workspace) &&
|
||||
Objects.equals(envName, machine.envName) &&
|
||||
Objects.equals(owner, machine.owner) &&
|
||||
status == machine.status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(machineConfig, id, machineRuntime, workspace, envName, owner, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helps to build complex {@link OldMachineImpl machine impl}.
|
||||
*
|
||||
* @see OldMachineImpl#builder()
|
||||
*/
|
||||
public static class MachineImplBuilder {
|
||||
|
||||
private OldMachineConfig machineConfig;
|
||||
private String id;
|
||||
private String envName;
|
||||
private String owner;
|
||||
private String workspaceId;
|
||||
private MachineStatus machineStatus;
|
||||
private Machine machine;
|
||||
|
||||
public OldMachineImpl build() {
|
||||
return new OldMachineImpl(machineConfig,
|
||||
id,
|
||||
workspaceId,
|
||||
envName,
|
||||
owner,
|
||||
machineStatus,
|
||||
machine);
|
||||
}
|
||||
|
||||
public MachineImplBuilder fromMachine(OldMachine machine) {
|
||||
this.envName = machine.getEnvName();
|
||||
this.id = machine.getId();
|
||||
this.machineConfig = machine.getConfig();
|
||||
this.machine = machine.getRuntime();
|
||||
this.machineStatus = machine.getStatus();
|
||||
this.owner = machine.getOwner();
|
||||
this.workspaceId = machine.getWorkspaceId();
|
||||
return this;
|
||||
}
|
||||
|
||||
public MachineImplBuilder setConfig(OldMachineConfig machineConfig) {
|
||||
this.machineConfig = machineConfig;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MachineImplBuilder setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MachineImplBuilder setStatus(MachineStatus status) {
|
||||
this.machineStatus = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MachineImplBuilder setEnvName(String envName) {
|
||||
this.envName = envName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MachineImplBuilder setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MachineImplBuilder setWorkspaceId(String workspaceId) {
|
||||
this.workspaceId = workspaceId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MachineImplBuilder setRuntime(Machine machine) {
|
||||
this.machine = machine;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,124 +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.machine.server.model.impl;
|
||||
|
||||
import org.eclipse.che.api.core.model.machine.OldServer;
|
||||
import org.eclipse.che.api.core.model.machine.ServerProperties;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Data object for {@link OldServer}.
|
||||
*
|
||||
* @author Eugene Voevodin
|
||||
* @author Alexander Garagatyi
|
||||
*/
|
||||
public class OldServerImpl implements OldServer {
|
||||
|
||||
private String ref;
|
||||
private String protocol;
|
||||
private String address;
|
||||
private String url;
|
||||
private ServerPropertiesImpl properties;
|
||||
|
||||
public OldServerImpl(String ref, String protocol, String address, String url, ServerProperties properties) {
|
||||
this.ref = ref;
|
||||
this.protocol = protocol;
|
||||
this.address = address;
|
||||
this.url = url;
|
||||
if (properties != null) {
|
||||
this.properties = new ServerPropertiesImpl(properties);
|
||||
}
|
||||
}
|
||||
|
||||
public OldServerImpl(OldServer server) {
|
||||
this(server.getRef(), server.getProtocol(), server.getAddress(), server.getUrl(), server.getProperties());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRef() {
|
||||
return ref;
|
||||
}
|
||||
|
||||
public void setRef(String ref) {
|
||||
this.ref = ref;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public void setProtocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerProperties getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(ServerPropertiesImpl properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof OldServerImpl)) return false;
|
||||
final OldServerImpl other = (OldServerImpl)o;
|
||||
return Objects.equals(ref, other.ref) &&
|
||||
Objects.equals(protocol, other.protocol) &&
|
||||
Objects.equals(address, other.address) &&
|
||||
Objects.equals(url, other.url) &&
|
||||
Objects.equals(properties, other.properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
hash = hash * 31 + Objects.hashCode(ref);
|
||||
hash = hash * 31 + Objects.hashCode(protocol);
|
||||
hash = hash * 31 + Objects.hashCode(address);
|
||||
hash = hash * 31 + Objects.hashCode(url);
|
||||
hash = hash * 31 + Objects.hashCode(properties);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OldServerImpl{" +
|
||||
"ref='" + ref + '\'' +
|
||||
", protocol='" + protocol + '\'' +
|
||||
", address='" + address + '\'' +
|
||||
", url='" + url + '\'' +
|
||||
", properties='" + properties + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -1,49 +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.machine.server.model.impl.adapter;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import org.eclipse.che.api.core.model.machine.MachineSource;
|
||||
import org.eclipse.che.api.machine.server.model.impl.MachineSourceImpl;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
* Type adapter for {@link MachineSource}.
|
||||
*
|
||||
* @author Florent Benoit
|
||||
*/
|
||||
public class MachineSourceAdapter implements JsonDeserializer<MachineSource>, JsonSerializer<MachineSource> {
|
||||
|
||||
@Override
|
||||
public MachineSource deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException {
|
||||
return context.deserialize(jsonElement, MachineSourceImpl.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(MachineSource machineSource, Type type, JsonSerializationContext context) {
|
||||
final JsonObject jsonObject = new JsonObject();
|
||||
|
||||
// we can't rely on MachineSourceImpl as custom InstanceProvider can build their own implementation
|
||||
jsonObject.addProperty("content", machineSource.getContent());
|
||||
jsonObject.addProperty("location", machineSource.getLocation());
|
||||
jsonObject.addProperty("type", machineSource.getType());
|
||||
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,139 +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.machine.server.spi;
|
||||
|
||||
import org.eclipse.che.api.core.NotFoundException;
|
||||
import org.eclipse.che.api.core.model.workspace.config.Command;
|
||||
import org.eclipse.che.api.core.model.machine.OldMachine;
|
||||
import org.eclipse.che.api.core.model.machine.MachineSource;
|
||||
import org.eclipse.che.api.core.model.machine.MachineStatus;
|
||||
import org.eclipse.che.api.core.util.LineConsumer;
|
||||
import org.eclipse.che.api.machine.server.exception.MachineException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Representation of machine instance in implementation specific way.
|
||||
*
|
||||
* @author gazarenkov
|
||||
* @author Alexander Garagatyi
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public interface Instance extends OldMachine {
|
||||
|
||||
void setStatus(MachineStatus status);
|
||||
|
||||
LineConsumer getLogger();
|
||||
|
||||
/**
|
||||
* Get {@link InstanceProcess} by its id
|
||||
*
|
||||
* @param pid
|
||||
* id of the process
|
||||
* @throws NotFoundException
|
||||
* if process with specified id is not found. Process can be finished already or doesn't exist.
|
||||
* @throws MachineException
|
||||
* if any other error occurs
|
||||
*/
|
||||
InstanceProcess getProcess(int pid) throws NotFoundException, MachineException;
|
||||
|
||||
/**
|
||||
* Get list of all running processes in the instance
|
||||
*
|
||||
* @return list of running processes or empty list if no process is running
|
||||
* @throws MachineException
|
||||
* if any error occurs on the processes list retrieving
|
||||
*/
|
||||
List<InstanceProcess> getProcesses() throws MachineException;
|
||||
|
||||
/**
|
||||
* Create process from command line.
|
||||
* Returned {@link InstanceProcess#getPid()} should return unique pid on this stage.
|
||||
* This pid allow to control process from clients and save process logs if needed.
|
||||
*
|
||||
* @param command
|
||||
* command from which process should be created
|
||||
* @param outputChannel
|
||||
* websocket chanel for execution logs
|
||||
* @return {@link InstanceProcess} with unique pid, that can't be used in future for other process of instance
|
||||
* @throws MachineException
|
||||
* if error occurs on creating process
|
||||
*/
|
||||
InstanceProcess createProcess(Command command, String outputChannel) throws MachineException;
|
||||
|
||||
/**
|
||||
* Save state of the instance
|
||||
*
|
||||
* @return {@code InstanceSnapshotKey} that describe implementation specific keys of snapshot
|
||||
* @throws MachineException
|
||||
* if error occurs on storing state of the instance
|
||||
*/
|
||||
MachineSource saveToSnapshot() throws MachineException;
|
||||
|
||||
/**
|
||||
* Destroy instance
|
||||
*
|
||||
* @throws MachineException
|
||||
* if error occurs on instance destroying
|
||||
*/
|
||||
void destroy() throws MachineException;
|
||||
|
||||
/**
|
||||
* Returns {@link InstanceNode} that represents server where machine is launched
|
||||
*/
|
||||
InstanceNode getNode();
|
||||
|
||||
/**
|
||||
* Reads file content from machine by specified path.
|
||||
*
|
||||
* @param filePath
|
||||
* path to file on machine instance
|
||||
* @param startFrom
|
||||
* line number to start reading from
|
||||
* @param limit
|
||||
* limitation on line
|
||||
* @return file content
|
||||
* @throws MachineException
|
||||
* if any error occurs with file reading
|
||||
*/
|
||||
String readFileContent(String filePath, int startFrom, int limit) throws MachineException;
|
||||
|
||||
|
||||
/**
|
||||
* Copies files from specified machine into current machine.
|
||||
*
|
||||
* @param sourceMachine
|
||||
* source machine
|
||||
* @param sourcePath
|
||||
* path to file or directory inside specified machine
|
||||
* @param targetPath
|
||||
* path to destination file or directory inside machine
|
||||
* @param overwriteDirNonDir
|
||||
* If "false" then it will be an error if unpacking the given content would cause
|
||||
* an existing directory to be replaced with a non-directory and vice versa.
|
||||
* @throws MachineException
|
||||
* if any error occurs when files are being copied
|
||||
*/
|
||||
void copy(Instance sourceMachine, String sourcePath, String targetPath, boolean overwriteDirNonDir) throws MachineException;
|
||||
|
||||
/**
|
||||
* Copies files from CHE server into current machine.
|
||||
*
|
||||
* @param sourcePath
|
||||
* path to file or directory inside CHE server
|
||||
* @param targetPath
|
||||
* path to destination file or directory inside machine
|
||||
* @throws MachineException
|
||||
* if any error occurs when files are being copied
|
||||
*/
|
||||
void copy(String sourcePath, String targetPath) throws MachineException;
|
||||
}
|
||||
|
|
@ -1,25 +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.machine.server.spi;
|
||||
|
||||
/**
|
||||
* Represents server where machine is launched
|
||||
*
|
||||
* @author Alexander Garagatyi
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public interface InstanceNode {
|
||||
/**
|
||||
* Host of the server where machine is launched
|
||||
*/
|
||||
String getHost();
|
||||
}
|
||||
|
|
@ -1,70 +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.machine.server.spi;
|
||||
|
||||
import org.eclipse.che.api.core.ConflictException;
|
||||
import org.eclipse.che.api.core.NotFoundException;
|
||||
import org.eclipse.che.api.core.util.LineConsumer;
|
||||
import org.eclipse.che.api.machine.server.exception.MachineException;
|
||||
import org.eclipse.che.api.core.model.machine.MachineProcess;
|
||||
|
||||
/**
|
||||
* Represents process in the machine created by command.
|
||||
*
|
||||
* @author andrew00x
|
||||
* @author Alexander Garagatyi
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public interface InstanceProcess extends MachineProcess {
|
||||
/**
|
||||
* Starts process in the background.
|
||||
*
|
||||
* @throws org.eclipse.che.api.core.ConflictException
|
||||
* if process is started already
|
||||
* @throws MachineException
|
||||
* if internal error occurs
|
||||
* @see #start()
|
||||
* @see #isAlive()
|
||||
*/
|
||||
void start() throws ConflictException, MachineException;
|
||||
|
||||
/**
|
||||
* Starts process.
|
||||
*
|
||||
* @param output
|
||||
* consumer for process' output. If this parameter is {@code null} process started in the background. If this parameter is
|
||||
* specified then this method is blocked until process is running.
|
||||
* @throws org.eclipse.che.api.core.ConflictException
|
||||
* if process is started already
|
||||
* @throws MachineException
|
||||
* if internal error occurs
|
||||
*/
|
||||
void start(LineConsumer output) throws ConflictException, MachineException;
|
||||
|
||||
/**
|
||||
* Kills this process.
|
||||
*
|
||||
* @throws MachineException
|
||||
* if internal error occurs
|
||||
*/
|
||||
void kill() throws MachineException;
|
||||
|
||||
/**
|
||||
* Check if process is alive
|
||||
*
|
||||
* @throws NotFoundException
|
||||
* if process is not found. It possible if it is finished, was killed.
|
||||
* @throws MachineException
|
||||
* if internal error occurs
|
||||
*/
|
||||
void checkAlive() throws NotFoundException, MachineException;
|
||||
}
|
||||
|
|
@ -1,85 +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.machine.server.spi;
|
||||
|
||||
import org.eclipse.che.api.core.NotFoundException;
|
||||
import org.eclipse.che.api.core.model.machine.OldMachine;
|
||||
import org.eclipse.che.api.core.model.machine.MachineSource;
|
||||
import org.eclipse.che.api.core.model.machine.OldMachineConfig;
|
||||
import org.eclipse.che.api.core.model.machine.OldRecipe;
|
||||
import org.eclipse.che.api.core.util.LineConsumer;
|
||||
import org.eclipse.che.api.machine.server.exception.InvalidRecipeException;
|
||||
import org.eclipse.che.api.machine.server.exception.MachineException;
|
||||
import org.eclipse.che.api.machine.server.exception.SnapshotException;
|
||||
import org.eclipse.che.api.machine.server.exception.SourceNotFoundException;
|
||||
import org.eclipse.che.api.machine.server.exception.UnsupportedRecipeException;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Provides instances of {@link Instance} in implementation specific way.
|
||||
*
|
||||
* @author gazarenkov
|
||||
* @author Alexander Garagatyi
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public interface InstanceProvider {
|
||||
/**
|
||||
* Gets type of instance that this provider supports. Must be unique per system.
|
||||
*
|
||||
* @return type of instance that this provider supports
|
||||
*/
|
||||
String getType();
|
||||
|
||||
/**
|
||||
* Gets supported recipe types.
|
||||
*
|
||||
* @return supported recipe types
|
||||
* @see OldRecipe#getType()
|
||||
*/
|
||||
Set<String> getRecipeTypes();
|
||||
|
||||
/**
|
||||
* Creates instance from scratch or by reusing a previously one by using specified {@link org.eclipse.che.api.core.model.machine.MachineSource}
|
||||
* data in {@link OldMachineConfig}.
|
||||
*
|
||||
* @param machine
|
||||
* machine description
|
||||
* @param creationLogsOutput
|
||||
* output for instance creation logs
|
||||
* @return newly created {@link Instance}
|
||||
* @throws UnsupportedRecipeException
|
||||
* if specified {@code recipe} is not supported
|
||||
* @throws InvalidRecipeException
|
||||
* if {@code recipe} is invalid
|
||||
* @throws NotFoundException
|
||||
* if instance described by {@link org.eclipse.che.api.core.model.machine.MachineSource} doesn't exists
|
||||
* @throws MachineException
|
||||
* if other error occurs
|
||||
*/
|
||||
Instance createInstance(OldMachine machine,
|
||||
LineConsumer creationLogsOutput) throws UnsupportedRecipeException,
|
||||
InvalidRecipeException,
|
||||
SourceNotFoundException,
|
||||
NotFoundException,
|
||||
MachineException;
|
||||
|
||||
/**
|
||||
* Removes snapshot of the instance in implementation specific way.
|
||||
*
|
||||
* @param machineSource
|
||||
* contains implementation specific key of the snapshot of the instance that should be removed
|
||||
* @throws SnapshotException
|
||||
* if exception occurs on instance snapshot removal
|
||||
*/
|
||||
void removeInstanceSnapshot(MachineSource machineSource) throws SnapshotException;
|
||||
}
|
||||
|
|
@ -1,39 +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.machine.server.spi.impl;
|
||||
|
||||
import org.eclipse.che.api.core.model.machine.OldMachine;
|
||||
import org.eclipse.che.api.core.model.machine.MachineStatus;
|
||||
import org.eclipse.che.api.machine.server.model.impl.MachineImpl;
|
||||
import org.eclipse.che.api.machine.server.model.impl.OldMachineImpl;
|
||||
import org.eclipse.che.api.machine.server.spi.Instance;
|
||||
|
||||
/**
|
||||
* @author Alexander Garagatyi
|
||||
*/
|
||||
public abstract class AbstractInstance extends OldMachineImpl implements Instance {
|
||||
public AbstractInstance(OldMachine machine) {
|
||||
super(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized MachineStatus getStatus() {
|
||||
return super.getStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setStatus(MachineStatus status) {
|
||||
super.setStatus(status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract MachineImpl getRuntime();
|
||||
}
|
||||
|
|
@ -1,83 +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.machine.server.spi.impl;
|
||||
|
||||
import org.eclipse.che.api.core.model.workspace.config.Command;
|
||||
import org.eclipse.che.api.machine.server.spi.InstanceProcess;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Alexander Garagatyi
|
||||
*/
|
||||
public abstract class AbstractMachineProcess implements InstanceProcess {
|
||||
private final String name;
|
||||
private final String commandLine;
|
||||
private final String type;
|
||||
private final Map<String, String> attributes;
|
||||
private final int pid;
|
||||
private final String outputChannel;
|
||||
|
||||
public AbstractMachineProcess(String name,
|
||||
String commandLine,
|
||||
String type,
|
||||
Map<String, String> attributes,
|
||||
int pid,
|
||||
String outputChannel) {
|
||||
this.name = name;
|
||||
this.commandLine = commandLine;
|
||||
this.type = type;
|
||||
this.attributes = attributes;
|
||||
this.outputChannel = outputChannel;
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public AbstractMachineProcess(Command command,
|
||||
int pid,
|
||||
String outputChannel) {
|
||||
this.name = command.getName();
|
||||
this.commandLine = command.getCommandLine();
|
||||
this.type = command.getType();
|
||||
this.attributes = command.getAttributes();
|
||||
this.pid = pid;
|
||||
this.outputChannel = outputChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOutputChannel() {
|
||||
return outputChannel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandLine() {
|
||||
return commandLine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,70 +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.machine.server.model.impl.adapter;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
|
||||
import org.eclipse.che.api.core.model.machine.MachineSource;
|
||||
import org.eclipse.che.api.machine.server.model.impl.MachineSourceImpl;
|
||||
import org.mockito.Mockito;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Test {@link MachineSourceAdapter} on serialization
|
||||
*
|
||||
* @author Florent Benoit
|
||||
*/
|
||||
public class MachineSourceAdapterTest {
|
||||
|
||||
/**
|
||||
* Check we can transform object into JSON and JSON into object
|
||||
*/
|
||||
@Test
|
||||
public void testSerializeAndDeserialize() {
|
||||
|
||||
MachineSourceAdapter machineSourceAdapter = spy(new MachineSourceAdapter());
|
||||
|
||||
Gson gson = new GsonBuilder().registerTypeAdapter(MachineSource.class, machineSourceAdapter).setPrettyPrinting().create();
|
||||
|
||||
final String TYPE = "myType";
|
||||
final String LOCATION = "myLocation";
|
||||
final String CONTENT = "myContent";
|
||||
|
||||
// serialize
|
||||
MachineSource machineSource = new MachineSourceImpl(TYPE).setLocation(LOCATION).setContent(CONTENT);
|
||||
String json = gson.toJson(machineSource, MachineSource.class);
|
||||
assertNotNull(json);
|
||||
|
||||
// verify we called serializer
|
||||
Mockito.verify(machineSourceAdapter).serialize(eq(machineSource), eq(MachineSource.class), any(JsonSerializationContext.class));
|
||||
|
||||
// now deserialize
|
||||
MachineSource machineSourceDeserialize = gson.fromJson(new StringReader(json), MachineSource.class);
|
||||
assertNotNull(machineSourceDeserialize);
|
||||
assertEquals(machineSourceDeserialize.getLocation(), LOCATION);
|
||||
assertEquals(machineSourceDeserialize.getType(), TYPE);
|
||||
assertEquals(machineSourceDeserialize.getContent(), CONTENT);
|
||||
// verify we called deserializer
|
||||
Mockito.verify(machineSourceAdapter).deserialize(any(JsonElement.class), eq(MachineSource.class), any(JsonDeserializationContext.class));
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
org.eclipse.che.api.machine.server.jpa.JpaTckModule
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
<?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
|
||||
|
||||
-->
|
||||
<configuration>
|
||||
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%-41(%date[%.25thread]) %-45([%-5level] [%.30logger{30} %L]) - %msg%n%nopex</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="stdout"/>
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
|
|
@ -69,10 +69,6 @@
|
|||
<groupId>org.eclipse.che.core</groupId>
|
||||
<artifactId>che-core-api-dto</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-machine-shared</artifactId>
|
||||
|
|
|
|||
|
|
@ -8,9 +8,8 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.machine.server.event;
|
||||
package org.eclipse.che.api.recipe;
|
||||
|
||||
import org.eclipse.che.api.machine.server.recipe.OldRecipeImpl;
|
||||
import org.eclipse.che.core.db.cascade.event.RemoveEvent;
|
||||
|
||||
/**
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.machine.server.jpa;
|
||||
package org.eclipse.che.api.recipe;
|
||||
|
||||
import com.google.inject.persist.Transactional;
|
||||
|
||||
|
|
@ -17,10 +17,6 @@ import org.eclipse.che.api.core.ConflictException;
|
|||
import org.eclipse.che.api.core.NotFoundException;
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.core.notification.EventService;
|
||||
import org.eclipse.che.api.machine.server.event.BeforeRecipeRemovedEvent;
|
||||
import org.eclipse.che.api.machine.server.event.RecipePersistedEvent;
|
||||
import org.eclipse.che.api.machine.server.recipe.OldRecipeImpl;
|
||||
import org.eclipse.che.api.machine.server.spi.RecipeDao;
|
||||
import org.eclipse.che.core.db.jpa.DuplicateKeyException;
|
||||
import org.eclipse.che.core.db.jpa.IntegrityConstraintViolationException;
|
||||
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.machine.server.recipe;
|
||||
package org.eclipse.che.api.recipe;
|
||||
|
||||
import org.eclipse.che.api.core.model.machine.OldRecipe;
|
||||
import org.eclipse.che.api.machine.shared.ManagedOldRecipe;
|
||||
|
|
@ -8,12 +8,11 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.machine.server.spi;
|
||||
package org.eclipse.che.api.recipe;
|
||||
|
||||
import org.eclipse.che.api.core.ConflictException;
|
||||
import org.eclipse.che.api.core.NotFoundException;
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.machine.server.recipe.OldRecipeImpl;
|
||||
import org.eclipse.che.api.machine.shared.ManagedOldRecipe;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.machine.server.recipe;
|
||||
package org.eclipse.che.api.recipe;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
|
|
@ -20,7 +20,6 @@ import com.google.inject.Inject;
|
|||
import org.eclipse.che.api.core.ConflictException;
|
||||
import org.eclipse.che.api.core.NotFoundException;
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.machine.server.spi.RecipeDao;
|
||||
import org.eclipse.che.commons.annotation.Nullable;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.machine.server.event;
|
||||
package org.eclipse.che.api.recipe;
|
||||
|
||||
import org.eclipse.che.api.core.notification.EventOrigin;
|
||||
import org.eclipse.che.api.machine.shared.ManagedOldRecipe;
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.machine.server.recipe;
|
||||
package org.eclipse.che.api.recipe;
|
||||
|
||||
import org.eclipse.che.api.core.ApiException;
|
||||
import org.eclipse.che.api.core.BadRequestException;
|
||||
|
|
@ -16,7 +16,6 @@ import org.eclipse.che.api.core.rest.Service;
|
|||
import org.eclipse.che.api.core.rest.annotations.GenerateLink;
|
||||
import org.eclipse.che.api.core.rest.shared.dto.Link;
|
||||
import org.eclipse.che.api.core.util.LinksHelper;
|
||||
import org.eclipse.che.api.machine.server.spi.RecipeDao;
|
||||
import org.eclipse.che.api.machine.shared.ManagedOldRecipe;
|
||||
import org.eclipse.che.api.machine.shared.dto.recipe.NewOldRecipe;
|
||||
import org.eclipse.che.api.machine.shared.dto.recipe.OldRecipeDescriptor;
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.machine.server.recipe.adapters;
|
||||
package org.eclipse.che.api.recipe.adapters;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
|
|
@ -19,7 +19,7 @@ import com.google.gson.JsonSerializationContext;
|
|||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import org.eclipse.che.api.core.model.machine.OldRecipe;
|
||||
import org.eclipse.che.api.machine.server.recipe.OldRecipeImpl;
|
||||
import org.eclipse.che.api.recipe.OldRecipeImpl;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.machine.server.recipe.providers;
|
||||
package org.eclipse.che.api.recipe.providers;
|
||||
|
||||
import com.google.inject.Provider;
|
||||
|
||||
|
|
@ -8,13 +8,12 @@
|
|||
* Contributors:
|
||||
* Codenvy, S.A. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.che.api.machine.server.util;
|
||||
package org.eclipse.che.api.workspace.server;
|
||||
|
||||
import org.eclipse.che.api.core.ServerException;
|
||||
import org.eclipse.che.api.core.model.machine.OldMachineConfig;
|
||||
import org.eclipse.che.api.core.model.machine.MachineSource;
|
||||
import org.eclipse.che.api.machine.server.exception.MachineException;
|
||||
import org.eclipse.che.api.machine.server.recipe.OldRecipeImpl;
|
||||
import org.eclipse.che.api.recipe.OldRecipeImpl;
|
||||
import org.eclipse.che.commons.env.EnvironmentContext;
|
||||
import org.eclipse.che.commons.lang.IoUtil;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -55,10 +54,10 @@ public class RecipeDownloader {
|
|||
* @param machineConfig
|
||||
* config used to get recipe location
|
||||
* @return recipe with set content and type
|
||||
* @throws MachineException
|
||||
* @throws ServerException
|
||||
* if any error occurs
|
||||
*/
|
||||
public OldRecipeImpl getRecipe(OldMachineConfig machineConfig) throws MachineException {
|
||||
public OldRecipeImpl getRecipe(OldMachineConfig machineConfig) throws ServerException {
|
||||
URL recipeUrl;
|
||||
File file = null;
|
||||
final String location = machineConfig.getSource().getLocation();
|
||||
|
|
@ -81,7 +80,7 @@ public class RecipeDownloader {
|
|||
return new OldRecipeImpl().withType(machineConfig.getSource().getType())
|
||||
.withScript(IoUtil.readAndCloseQuietly(new FileInputStream(file)));
|
||||
} catch (IOException | IllegalArgumentException e) {
|
||||
throw new MachineException(format("Failed to download recipe for machine %s. OldRecipe url %s. Error: %s",
|
||||
throw new ServerException(format("Failed to download recipe for machine %s. OldRecipe url %s. Error: %s",
|
||||
machineConfig.getName(),
|
||||
location,
|
||||
e.getLocalizedMessage()));
|
||||
|
|
@ -122,7 +121,7 @@ public class RecipeDownloader {
|
|||
|
||||
return IoUtil.readAndCloseQuietly(new FileInputStream(file));
|
||||
} catch (IOException | IllegalArgumentException | UriBuilderException e) {
|
||||
throw new MachineException(format("Failed to download recipe %s. Error: %s",
|
||||
throw new ServerException(format("Failed to download recipe %s. Error: %s",
|
||||
location,
|
||||
e.getLocalizedMessage()));
|
||||
} finally {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue