public WorkspaceConfigImplBuilder fromConfig(WorkspaceConfig workspaceConfig) { this.name = workspaceConfig.getName(); this.description = workspaceConfig.getDescription(); this.defaultEnvName = workspaceConfig.getDefaultEnv(); this.projects = workspaceConfig.getProjects(); this.commands = workspaceConfig.getCommands(); this.environments = workspaceConfig.getEnvironments(); return this; }
public WorkspaceImpl(Workspace workspace, Account account) { this( workspace.getId(), account, workspace.getConfig(), workspace.getRuntime(), workspace.getAttributes(), workspace.isTemporary(), workspace.getStatus()); }
public WarningImpl(Warning warning) { this.code = warning.getCode(); this.message = warning.getMessage(); }
private boolean isSshServerIsRunning(String machineName) { Workspace workspace = appContext.getWorkspace(); Runtime runtime = workspace.getRuntime(); if (runtime == null) { return false; } Machine machine = runtime.getMachines().get(machineName); if (machine == null) { return false; } Server server = machine.getServers().get(SERVER_SSH_REFERENCE); if (server == null) { return false; } return workspace.getStatus() == WorkspaceStatus.RUNNING; }
/** Checks whether the server is running in the machine. */ private boolean isServerRunning(String machineName, String serverName) { Workspace workspace = appContext.getWorkspace(); Runtime runtime = workspace.getRuntime(); if (runtime == null) { return false; } Machine machine = runtime.getMachines().get(machineName); if (machine == null) { return false; } Server server = machine.getServers().get(serverName); if (server == null) { return false; } return server.getStatus() == ServerStatus.RUNNING; }
/** Returns 'rel -> url' map of links for the given workspace. */ public Map<String, String> genLinks(Workspace workspace, ServiceContext serviceContext) throws ServerException { final UriBuilder uriBuilder = serviceContext.getServiceUriBuilder(); final LinkedHashMap<String, String> links = new LinkedHashMap<>(); links.put( LINK_REL_SELF, uriBuilder .clone() .path(WorkspaceService.class, "getByKey") .build(workspace.getId()) .toString()); links.put( LINK_REL_IDE_URL, uriBuilder .clone() .replacePath("") .path(workspace.getNamespace()) .path(workspace.getConfig().getName()) .build() .toString()); if (workspace.getStatus() != WorkspaceStatus.STOPPED) { addRuntimeLinks(links, workspace.getId(), serviceContext); } return links; }
private static EnvironmentImpl copyEnv(Workspace workspace, String envName) { requireNonNull(workspace, "Workspace should not be null."); requireNonNull(envName, "Environment name should not be null."); final Environment environment = workspace.getConfig().getEnvironments().get(envName); if (environment == null) { throw new IllegalArgumentException( format("Workspace '%s' doesn't contain environment '%s'", workspace.getId(), envName)); } return new EnvironmentImpl(environment); }
/** * Ensure workspace has running status, or throw IllegalStateException. * * @param workspace workspace description to get status and id. * @throws IllegalStateException if workspace with certain workspaceId doesn't have RUNNING * status. */ @Override public void ensureRunningStatus(Workspace workspace) throws IllegalStateException { if (workspace.getStatus() != WorkspaceStatus.RUNNING) { throw new IllegalStateException( format( "Workspace with id='%s' should has '%s' status, but its actual state='%s'", workspace.getId(), WorkspaceStatus.RUNNING, workspace.getStatus())); } }
/** * Get {@link WorkspaceProbes} for a whole workspace runtime * * @throws InfrastructureException when the operation fails */ public WorkspaceProbes getProbes(RuntimeIdentity runtimeId, Runtime runtime) throws InfrastructureException { return getProbes(runtimeId, runtime.getMachines()); }
@Override public void onEvent(WorkspaceStatusEvent event) { if (WorkspaceStatus.STOPPED.equals(event.getStatus())) { tokenRegistry.removeTokens(event.getWorkspaceId()); } }
public WorkspaceStatus getWorkspaceStatusAssociatedWithFactory() throws Exception { return workspaceServiceClient .getByName(factoryDto.getWorkspace().getName(), owner.getName()) .getStatus(); } }
@Override public int hashCode() { int hash = 7; hash = hash * 31 + (error != null ? error.hashCode() : 0); hash = hash * 31 + (status != null ? status.hashCode() : 0); hash = hash * 31 + (prevStatus != null ? prevStatus.hashCode() : 0); hash = hash * 31 + (workspaceId != null ? workspaceId.hashCode() : 0); return hash; }
public WorkspaceConfigImpl(WorkspaceConfig workspaceConfig) { this( workspaceConfig.getName(), workspaceConfig.getDescription(), workspaceConfig.getDefaultEnv(), workspaceConfig.getCommands(), workspaceConfig.getProjects(), workspaceConfig.getEnvironments(), workspaceConfig.getAttributes()); }
/** Converts {@link Workspace} to {@link WorkspaceDto}. */ public static WorkspaceDto asDto(Workspace workspace) { WorkspaceDto workspaceDto = newDto(WorkspaceDto.class) .withId(workspace.getId()) .withStatus(workspace.getStatus()) .withNamespace(workspace.getNamespace()) .withTemporary(workspace.isTemporary()) .withAttributes(workspace.getAttributes()) .withConfig(asDto(workspace.getConfig())); if (workspace.getRuntime() != null) { RuntimeDto runtime = asDto(workspace.getRuntime()); workspaceDto.setRuntime(runtime); } return workspaceDto; }
public WarningImpl(Warning warning) { this(warning.getCode(), warning.getMessage()); }
public WorkspaceConfigImpl(WorkspaceConfig workspaceConfig) { this( workspaceConfig.getName(), workspaceConfig.getDescription(), workspaceConfig.getDefaultEnv(), workspaceConfig.getCommands(), workspaceConfig.getProjects(), workspaceConfig.getEnvironments(), workspaceConfig.getAttributes()); }
/** Converts {@link Warning} to {@link WarningDto}. */ public static WarningDto asDto(Warning warning) { return newDto(WarningDto.class).withCode(warning.getCode()).withMessage(warning.getMessage()); }
/** Sends stop workspace request. */ private void sendStopRequest(String workspaceName, String userName) throws Exception { if (!exists(workspaceName, userName)) { return; } Workspace workspace = getByName(workspaceName, userName); String apiUrl = getIdBasedUrl(workspace.getId()) + "/runtime/"; requestFactory.fromUrl(apiUrl).useDeleteMethod().request(); }