@Override public ComposeEnvironment setType(String type) { return (ComposeEnvironment) super.setType(type); }
protected InternalEnvironment(InternalEnvironment internalEnvironment) { this.recipe = internalEnvironment.getRecipe(); this.type = recipe != null ? recipe.getType() : null; this.machines = internalEnvironment.getMachines(); this.warnings = new CopyOnWriteArrayList<>(internalEnvironment.getWarnings()); this.attributes = internalEnvironment.getAttributes(); this.commands = internalEnvironment.getCommands(); }
private void addRamAttributes(Map<String, InternalMachineConfig> machines) { for (InternalMachineConfig machineConfig : machines.values()) { memoryProvisioner.provision(machineConfig, 0L, 0L); } }
@VisibleForTesting void addRamAttributes( Map<String, InternalMachineConfig> machines, Map<String, ComposeService> services) throws InfrastructureException { for (Entry<String, ComposeService> entry : services.entrySet()) { InternalMachineConfig machineConfig; if ((machineConfig = machines.get(entry.getKey())) == null) { machineConfig = new InternalMachineConfig(); machines.put(entry.getKey(), machineConfig); } memoryProvisioner.provision( machineConfig, entry.getValue().getMemLimit(), entry.getValue().getMemRequest()); } }
@Override public void provision(RuntimeIdentity id, InternalEnvironment internalEnvironment) throws InfrastructureException { for (InternalMachineConfig machineConfig : internalEnvironment.getMachines().values()) { LOG.debug("Start provisioning installer configs for workspace '{}'", id.getWorkspaceId()); fillEnv(machineConfig.getEnv(), machineConfig.getInstallers()); fillServers(id.getWorkspaceId(), machineConfig.getServers(), machineConfig.getInstallers()); } }
@Override public void provision(RuntimeIdentity id, InternalEnvironment internalEnvironment) throws InfrastructureException { LOG.debug("Provisioning machine names for workspace '{}'", id.getWorkspaceId()); for (Entry<String, InternalMachineConfig> machineEntry : internalEnvironment.getMachines().entrySet()) { machineEntry.getValue().getEnv().put(CHE_MACHINE_NAME_ENV_VAR, machineEntry.getKey()); } } }
@Override public void provision(RuntimeIdentity id, InternalEnvironment internalEnvironment) throws InfrastructureException { LOG.debug("Provisioning project volumes for workspace '{}'", id.getWorkspaceId()); Optional<String> wsAgentServerMachine = WsAgentMachineFinderUtil.getWsAgentServerMachine(internalEnvironment); if (wsAgentServerMachine.isPresent()) { InternalMachineConfig machineConfig = internalEnvironment.getMachines().get(wsAgentServerMachine.get()); machineConfig .getVolumes() .put(PROJECTS_VOLUME_NAME, new VolumeImpl().withPath(projectFolderPath)); } } }
private InternalEnvironment getInternalEnvironment(Environment environment) throws InfrastructureException, ValidationException, NotFoundException { final String recipeType = environment.getRecipe().getType(); final InternalEnvironmentFactory factory = environmentFactories.get(recipeType); if (factory == null) { throw new NotFoundException( format("InternalEnvironmentFactory is not configured for recipe type: '%s'", recipeType)); } return factory.create(environment); } }
protected InternalEnvironment( InternalRecipe recipe, Map<String, InternalMachineConfig> machines, List<Warning> warnings) { this.recipe = recipe; this.machines = machines; this.warnings = new CopyOnWriteArrayList<>(); if (warnings != null) { this.warnings.addAll(warnings); } this.type = recipe != null ? recipe.getType() : null; }
/** * Checks whether provided {@link InternalMachineConfig} contains wsagent installer or server. * * @param machineConfig machine config to check * @return true when wsagent server or installer is found in provided machine, false otherwise */ public static boolean containsWsAgentServerOrInstaller(InternalMachineConfig machineConfig) { return machineConfig.getServers().keySet().contains(SERVER_WS_AGENT_HTTP_REFERENCE) || InstallerFqn.idInInstallerList(WS_AGENT_INSTALLER, machineConfig.getInstallers()); }
/** * Returns content of recipe either by getting it from provided {@link Recipe} object or by * retrieving it from location set in provided recipe. * * @param recipe recipe of {@link org.eclipse.che.api.core.model.workspace.config.Environment} * @return recipe content * @throws NullPointerException when recipe is null * @throws IllegalArgumentException when both recipe content and location are null or empty */ public InternalRecipe getRecipe(Recipe recipe) throws InfrastructureException { Objects.requireNonNull(recipe, "Recipe should not be null"); Objects.requireNonNull(recipe.getType(), "Recipe type should not be null"); return new InternalRecipe(recipe.getType(), recipe.getContentType(), retrieveContent(recipe)); }
private String retrieveContent(Recipe recipe) throws InfrastructureException { if (recipe.getContent() != null && !recipe.getContent().isEmpty()) { // no downloading is needed return recipe.getContent(); } if (recipe.getLocation() == null || recipe.getLocation().isEmpty()) { throw new IllegalArgumentException("Neither content nor location are present in recipe"); } URL url = prepareURL(recipe.getLocation()); return downloadContent(url); }
/** * Checks whether provided {@link InternalMachineConfig} contains wsagent server. * * @param machineConfig machine config to check * @return true when wsagent server is found in provided machine, false otherwise */ public static boolean containsWsAgentServer(InternalMachineConfig machineConfig) { return machineConfig.getServers().keySet().contains(SERVER_WS_AGENT_HTTP_REFERENCE); }
/** * Validates the specified machine configs. * * @param machines machines configs to validate * @throws ValidationException when the specified environment is not valid */ public void validate(Map<String, InternalMachineConfig> machines) throws ValidationException { for (Entry<String, InternalMachineConfig> machineConfigEntry : machines.entrySet()) { validateMachine(machineConfigEntry.getKey(), machineConfigEntry.getValue()); } }
/** Returns warnings that occurred while runtime preparing and starting. */ public List<? extends Warning> getWarnings() { return context.getEnvironment().getWarnings(); }
@VisibleForTesting void addRamAttributes(Map<String, InternalMachineConfig> machines, Collection<Pod> pods) { for (Pod pod : pods) { for (Container container : pod.getSpec().getContainers()) { final String machineName = Names.machineName(pod, container); InternalMachineConfig machineConfig; if ((machineConfig = machines.get(machineName)) == null) { machineConfig = new InternalMachineConfig(); machines.put(machineName, machineConfig); } memoryProvisioner.provision( machineConfig, Containers.getRamLimit(container), Containers.getRamRequest(container)); } } }
@Override public void provision(RuntimeIdentity id, InternalEnvironment internalEnvironment) throws InfrastructureException { LOG.debug("Provisioning environment variables for workspace '{}'", id.getWorkspaceId()); for (EnvVarProvider envVarProvider : envVarProviders) { Pair<String, String> envVar = envVarProvider.get(id); if (envVar != null) { internalEnvironment .getMachines() .values() .forEach(m -> m.getEnv().putIfAbsent(envVar.first, envVar.second)); } } LOG.debug("Environment variables provisioning done for workspace '{}'", id.getWorkspaceId()); } }
void addRamAttributes(Map<String, InternalMachineConfig> machines) { // sets default ram limit and request attributes if not present for (InternalMachineConfig machineConfig : machines.values()) { memoryProvisioner.provision(machineConfig, 0L, 0L); } }
@Override public DockerfileEnvironment setType(String type) { return (DockerfileEnvironment) super.setType(type); }
@Override public DockerImageEnvironment setType(String type) { return (DockerImageEnvironment) super.setType(type); }