Search in sources :

Example 1 with Agent

use of org.eclipse.che.api.agent.shared.model.Agent in project che by eclipse.

the class WsMasterModule method configure.

@Override
protected void configure() {
    // db related components modules
    install(new com.google.inject.persist.jpa.JpaPersistModule("main"));
    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.workspace.server.jpa.WorkspaceJpaModule());
    // db configuration
    bind(DataSource.class).toProvider(org.eclipse.che.core.db.h2.H2DataSourceProvider.class);
    bind(SchemaInitializer.class).to(org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer.class);
    bind(org.eclipse.che.core.db.DBInitializer.class).asEagerSingleton();
    bind(PlaceholderReplacer.class).toProvider(org.eclipse.che.core.db.schema.impl.flyway.PlaceholderReplacerProvider.class);
    install(new org.eclipse.che.plugin.docker.compose.ComposeModule());
    bind(org.eclipse.che.api.user.server.CheUserCreator.class);
    bind(TokenValidator.class).to(org.eclipse.che.api.local.DummyTokenValidator.class);
    bind(org.eclipse.che.api.core.rest.ApiInfoService.class);
    bind(org.eclipse.che.api.project.server.template.ProjectTemplateDescriptionLoader.class).asEagerSingleton();
    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(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);
    bind(org.eclipse.che.api.workspace.server.stack.StackLoader.class);
    bind(org.eclipse.che.api.workspace.server.stack.StackService.class);
    bind(org.eclipse.che.api.workspace.server.TemporaryWorkspaceRemover.class);
    bind(org.eclipse.che.api.workspace.server.WorkspaceService.class);
    bind(org.eclipse.che.api.workspace.server.event.WorkspaceMessenger.class).asEagerSingleton();
    bind(org.eclipse.che.plugin.docker.machine.ext.DockerMachineExtServerChecker.class);
    bind(org.eclipse.che.plugin.docker.machine.ext.DockerMachineTerminalChecker.class);
    bind(org.eclipse.che.everrest.EverrestDownloadFileResponseFilter.class);
    bind(org.eclipse.che.everrest.ETagResponseFilter.class);
    bind(org.eclipse.che.api.agent.server.AgentRegistryService.class);
    bind(org.eclipse.che.security.oauth.OAuthAuthenticatorProvider.class).to(org.eclipse.che.security.oauth.OAuthAuthenticatorProviderImpl.class);
    bind(org.eclipse.che.api.auth.oauth.OAuthTokenProvider.class).to(org.eclipse.che.security.oauth.OAuthAuthenticatorTokenProvider.class);
    bind(org.eclipse.che.security.oauth.OAuthAuthenticationService.class);
    bind(org.eclipse.che.api.core.notification.WSocketEventBusServer.class);
    // additional ports for development of extensions
    Multibinder<org.eclipse.che.api.core.model.machine.ServerConf> machineServers = Multibinder.newSetBinder(binder(), org.eclipse.che.api.core.model.machine.ServerConf.class, Names.named("machine.docker.dev_machine.machine_servers"));
    machineServers.addBinding().toInstance(new org.eclipse.che.api.machine.server.model.impl.ServerConfImpl(Constants.WSAGENT_DEBUG_REFERENCE, "4403/tcp", "http", null));
    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);
    Multibinder.newSetBinder(binder(), String.class, Names.named("predefined.recipe.path")).addBinding().toInstance("predefined-recipes.json");
    bind(org.eclipse.che.api.workspace.server.WorkspaceValidator.class).to(org.eclipse.che.api.workspace.server.DefaultWorkspaceValidator.class);
    bind(org.eclipse.che.api.workspace.server.event.MachineStateListener.class).asEagerSingleton();
    // agents
    bind(org.eclipse.che.api.agent.server.AgentRegistry.class).to(org.eclipse.che.api.agent.server.impl.AgentRegistryImpl.class);
    Multibinder<Agent> agents = Multibinder.newSetBinder(binder(), Agent.class);
    agents.addBinding().to(SshAgent.class);
    agents.addBinding().to(UnisonAgent.class);
    agents.addBinding().to(ExecAgent.class);
    agents.addBinding().to(WsAgent.class);
    agents.addBinding().to(LSPhpAgent.class);
    agents.addBinding().to(LSPythonAgent.class);
    agents.addBinding().to(LSJsonAgent.class);
    agents.addBinding().to(LSCSharpAgent.class);
    agents.addBinding().to(LSTypeScriptAgent.class);
    Multibinder<AgentLauncher> launchers = Multibinder.newSetBinder(binder(), AgentLauncher.class);
    launchers.addBinding().to(WsAgentLauncher.class);
    launchers.addBinding().to(ExecAgentLauncher.class);
    launchers.addBinding().to(SshAgentLauncher.class);
    bindConstant().annotatedWith(Names.named("machine.ws_agent.run_command")).to("export JPDA_ADDRESS=\"4403\" && ~/che/ws-agent/bin/catalina.sh jpda run");
    bindConstant().annotatedWith(Names.named("machine.terminal_agent.run_command")).to("$HOME/che/terminal/che-websocket-terminal " + "-addr :4411 " + "-cmd ${SHELL_INTERPRETER} " + "-static $HOME/che/terminal/ " + "-logs-dir $HOME/che/exec-agent/logs");
    bind(org.eclipse.che.api.deploy.WsMasterAnalyticsAddresser.class);
    Multibinder<org.eclipse.che.api.machine.server.spi.InstanceProvider> machineImageProviderMultibinder = Multibinder.newSetBinder(binder(), org.eclipse.che.api.machine.server.spi.InstanceProvider.class);
    machineImageProviderMultibinder.addBinding().to(org.eclipse.che.plugin.docker.machine.DockerInstanceProvider.class);
    bind(org.eclipse.che.api.environment.server.MachineInstanceProvider.class).to(org.eclipse.che.plugin.docker.machine.MachineProviderImpl.class);
    install(new org.eclipse.che.api.core.rest.CoreRestModule());
    install(new org.eclipse.che.api.core.util.FileCleaner.FileCleanerModule());
    install(new org.eclipse.che.plugin.docker.machine.local.LocalDockerModule());
    install(new org.eclipse.che.api.machine.server.MachineModule());
    install(new org.eclipse.che.plugin.docker.machine.ext.DockerExtServerModule());
    install(new org.eclipse.che.swagger.deploy.DocsModule());
    install(new org.eclipse.che.plugin.machine.ssh.SshMachineModule());
    install(new org.eclipse.che.plugin.docker.machine.proxy.DockerProxyModule());
    install(new org.eclipse.che.commons.schedule.executor.ScheduleModule());
    final Multibinder<MessageBodyAdapter> adaptersMultibinder = Multibinder.newSetBinder(binder(), MessageBodyAdapter.class);
    adaptersMultibinder.addBinding().to(WorkspaceConfigMessageBodyAdapter.class);
    adaptersMultibinder.addBinding().to(WorkspaceMessageBodyAdapter.class);
    adaptersMultibinder.addBinding().to(StackMessageBodyAdapter.class);
    final MessageBodyAdapterInterceptor interceptor = new MessageBodyAdapterInterceptor();
    requestInjection(interceptor);
    bindInterceptor(subclassesOf(CheJsonProvider.class), names("readFrom"), interceptor);
    bind(org.eclipse.che.api.workspace.server.WorkspaceFilesCleaner.class).to(org.eclipse.che.plugin.docker.machine.cleaner.LocalWorkspaceFilesCleaner.class);
    bind(org.eclipse.che.api.environment.server.InfrastructureProvisioner.class).to(org.eclipse.che.plugin.docker.machine.local.LocalCheInfrastructureProvisioner.class);
    // system components
    bind(org.eclipse.che.api.system.server.SystemService.class);
    bind(org.eclipse.che.api.system.server.SystemEventsWebsocketBroadcaster.class).asEagerSingleton();
    install(new org.eclipse.che.plugin.docker.machine.dns.DnsResolversModule());
}
Also used : TokenValidator(org.eclipse.che.api.user.server.TokenValidator) CheJsonProvider(org.eclipse.che.api.core.rest.CheJsonProvider) MessageBodyAdapter(org.eclipse.che.api.core.rest.MessageBodyAdapter) WorkspaceConfigMessageBodyAdapter(org.eclipse.che.api.workspace.server.WorkspaceConfigMessageBodyAdapter) WorkspaceMessageBodyAdapter(org.eclipse.che.api.workspace.server.WorkspaceMessageBodyAdapter) StackMessageBodyAdapter(org.eclipse.che.api.workspace.server.stack.StackMessageBodyAdapter) Agent(org.eclipse.che.api.agent.shared.model.Agent) LSJsonAgent(org.eclipse.che.api.agent.LSJsonAgent) LSCSharpAgent(org.eclipse.che.api.agent.LSCSharpAgent) LSPhpAgent(org.eclipse.che.api.agent.LSPhpAgent) ExecAgent(org.eclipse.che.api.agent.ExecAgent) LSTypeScriptAgent(org.eclipse.che.api.agent.LSTypeScriptAgent) UnisonAgent(org.eclipse.che.api.agent.UnisonAgent) SshAgent(org.eclipse.che.api.agent.SshAgent) LSPythonAgent(org.eclipse.che.api.agent.LSPythonAgent) WsAgent(org.eclipse.che.api.agent.WsAgent) AgentLauncher(org.eclipse.che.api.agent.server.launcher.AgentLauncher) WsAgentLauncher(org.eclipse.che.api.agent.WsAgentLauncher) ExecAgentLauncher(org.eclipse.che.api.agent.ExecAgentLauncher) SshAgentLauncher(org.eclipse.che.api.agent.SshAgentLauncher) DataSource(javax.sql.DataSource) MessageBodyAdapterInterceptor(org.eclipse.che.api.core.rest.MessageBodyAdapterInterceptor) PlaceholderReplacer(org.flywaydb.core.internal.util.PlaceholderReplacer) SchemaInitializer(org.eclipse.che.core.db.schema.SchemaInitializer)

Example 2 with Agent

use of org.eclipse.che.api.agent.shared.model.Agent in project che by eclipse.

the class AgentSorter method doSort.

private void doSort(AgentKey agentKey, List<AgentKey> sorted, Set<String> pending) throws AgentException {
    String agentId = agentKey.getId();
    Optional<AgentKey> alreadySorted = sorted.stream().filter(k -> k.getId().equals(agentId)).findFirst();
    if (alreadySorted.isPresent()) {
        return;
    }
    pending.add(agentId);
    Agent agent = agentRegistry.getAgent(agentKey);
    for (String dependency : agent.getDependencies()) {
        if (pending.contains(dependency)) {
            throw new AgentException(String.format("Agents circular dependency found between '%s' and '%s'", dependency, agentId));
        }
        doSort(AgentKeyImpl.parse(dependency), sorted, pending);
    }
    sorted.add(agentKey);
    pending.remove(agentId);
}
Also used : Agent(org.eclipse.che.api.agent.shared.model.Agent) AgentKeyImpl(org.eclipse.che.api.agent.shared.model.impl.AgentKeyImpl) Inject(com.google.inject.Inject) Set(java.util.Set) AgentException(org.eclipse.che.api.agent.server.exception.AgentException) Nullable(org.eclipse.che.commons.annotation.Nullable) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) List(java.util.List) Optional(java.util.Optional) AgentKey(org.eclipse.che.api.agent.shared.model.AgentKey) Singleton(com.google.inject.Singleton) AgentRegistry(org.eclipse.che.api.agent.server.AgentRegistry) AgentKey(org.eclipse.che.api.agent.shared.model.AgentKey) Agent(org.eclipse.che.api.agent.shared.model.Agent) AgentException(org.eclipse.che.api.agent.server.exception.AgentException)

Example 3 with Agent

use of org.eclipse.che.api.agent.shared.model.Agent in project che by eclipse.

the class AgentRegistryImplTest method shouldReturnAgentByIdAndVersion.

@Test(dataProvider = "AgentKeys")
public void shouldReturnAgentByIdAndVersion(String id, String version) throws Exception {
    Agent agent = registry.getAgent(new AgentKeyImpl(id, version));
    assertNotNull(agent);
    assertEquals(agent.getName(), String.format("%s:%s", id, (version == null ? "latest" : version)));
}
Also used : Agent(org.eclipse.che.api.agent.shared.model.Agent) AgentKeyImpl(org.eclipse.che.api.agent.shared.model.impl.AgentKeyImpl) Test(org.testng.annotations.Test)

Example 4 with Agent

use of org.eclipse.che.api.agent.shared.model.Agent in project che by eclipse.

the class AbstractAgentLauncherTest method shouldThrowServerExceptionIfMachineExceptionIsThrownByAgentCheck.

@Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "agent launcher test exception")
public void shouldThrowServerExceptionIfMachineExceptionIsThrownByAgentCheck() throws Exception {
    // given
    when(agentChecker.isLaunched(any(Agent.class), any(InstanceProcess.class), any(Instance.class))).thenThrow(new MachineException("agent launcher test exception"));
    // when
    launcher.launch(machine, agent);
}
Also used : Agent(org.eclipse.che.api.agent.shared.model.Agent) Instance(org.eclipse.che.api.machine.server.spi.Instance) MachineException(org.eclipse.che.api.machine.server.exception.MachineException) InstanceProcess(org.eclipse.che.api.machine.server.spi.InstanceProcess) Test(org.testng.annotations.Test)

Example 5 with Agent

use of org.eclipse.che.api.agent.shared.model.Agent in project che by eclipse.

the class WorkspaceRuntimes method launchAgents.

protected void launchAgents(Instance instance, List<String> agents) throws ServerException {
    try {
        for (AgentKey agentKey : agentSorter.sort(agents)) {
            if (!Thread.currentThread().isInterrupted()) {
                LOG.info("Launching '{}' agent at workspace {}", agentKey.getId(), instance.getWorkspaceId());
                Agent agent = agentRegistry.getAgent(agentKey);
                AgentLauncher launcher = launcherFactory.find(agentKey.getId(), instance.getConfig().getType());
                launcher.launch(instance, agent);
            }
        }
    } catch (AgentException e) {
        throw new MachineException(e.getMessage(), e);
    }
}
Also used : AgentKey(org.eclipse.che.api.agent.shared.model.AgentKey) Agent(org.eclipse.che.api.agent.shared.model.Agent) AgentLauncher(org.eclipse.che.api.agent.server.launcher.AgentLauncher) AgentException(org.eclipse.che.api.agent.server.exception.AgentException) MachineException(org.eclipse.che.api.machine.server.exception.MachineException)

Aggregations

Agent (org.eclipse.che.api.agent.shared.model.Agent)9 Test (org.testng.annotations.Test)5 MachineException (org.eclipse.che.api.machine.server.exception.MachineException)4 Instance (org.eclipse.che.api.machine.server.spi.Instance)4 AgentKey (org.eclipse.che.api.agent.shared.model.AgentKey)3 LineConsumer (org.eclipse.che.api.core.util.LineConsumer)3 AgentException (org.eclipse.che.api.agent.server.exception.AgentException)2 AgentLauncher (org.eclipse.che.api.agent.server.launcher.AgentLauncher)2 AgentKeyImpl (org.eclipse.che.api.agent.shared.model.impl.AgentKeyImpl)2 InstanceProcess (org.eclipse.che.api.machine.server.spi.InstanceProcess)2 Inject (com.google.inject.Inject)1 Singleton (com.google.inject.Singleton)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 DataSource (javax.sql.DataSource)1 ExecAgent (org.eclipse.che.api.agent.ExecAgent)1 ExecAgentLauncher (org.eclipse.che.api.agent.ExecAgentLauncher)1