private void handleStartupSuccess(Workspace workspace) { workspace.getAttributes().remove(STOPPED_ATTRIBUTE_NAME); workspace.getAttributes().remove(STOPPED_ABNORMALLY_ATTRIBUTE_NAME); workspace.getAttributes().remove(ERROR_MESSAGE_ATTRIBUTE_NAME); try { updateWorkspace(workspace.getId(), workspace); } catch (NotFoundException | ServerException | ValidationException | ConflictException e) { LOG.warn( String.format( "Cannot clear error status status of the workspace %s. Error is: %s", workspace.getId(), e.getMessage())); } }
private void handleStartupError(Workspace workspace, Throwable t) { workspace .getAttributes() .put( ERROR_MESSAGE_ATTRIBUTE_NAME, t instanceof RuntimeException ? t.getCause().getMessage() : t.getMessage()); workspace.getAttributes().put(STOPPED_ATTRIBUTE_NAME, Long.toString(currentTimeMillis())); workspace.getAttributes().put(STOPPED_ABNORMALLY_ATTRIBUTE_NAME, Boolean.toString(true)); try { updateWorkspace(workspace.getId(), workspace); } catch (NotFoundException | ServerException | ValidationException | ConflictException e) { LOG.warn( String.format( "Cannot set error status of the workspace %s. Error is: %s", workspace.getId(), e.getMessage())); } }
public WorkspaceImpl(Workspace workspace, Account account) { this( workspace.getId(), account, workspace.getConfig(), workspace.getRuntime(), workspace.getAttributes(), workspace.isTemporary(), workspace.getStatus()); }
/** * Updates an existing workspace with a new configuration. * * <p> * * <p>Replace strategy is used for workspace update, it means that existing workspace data will be * replaced with given {@code update}. * * @param update workspace update * @return updated instance of the workspace * @throws NullPointerException when either {@code workspaceId} or {@code update} is null * @throws NotFoundException when workspace with given id doesn't exist * @throws ConflictException when any conflict occurs (e.g Workspace with such name already exists * in {@code namespace}) * @throws ServerException when any other error occurs */ public WorkspaceImpl updateWorkspace(String id, Workspace update) throws ConflictException, ServerException, NotFoundException, ValidationException { requireNonNull(id, "Required non-null workspace id"); requireNonNull(update, "Required non-null workspace update"); requireNonNull(update.getConfig(), "Required non-null workspace configuration update"); validator.validateConfig(update.getConfig()); validator.validateAttributes(update.getAttributes()); WorkspaceImpl workspace = workspaceDao.get(id); workspace.setConfig(new WorkspaceConfigImpl(update.getConfig())); workspace.setAttributes(update.getAttributes()); workspace.getAttributes().put(UPDATED_ATTRIBUTE_NAME, Long.toString(currentTimeMillis())); workspace.setTemporary(update.isTemporary()); return normalizeState(workspaceDao.update(workspace), true); }
sessionUserNameOr(workspace.getAttributes().get(WORKSPACE_STOPPED_BY)), "undefined"); LOG.info( "Workspace '{}/{}' with id '{}' is stopping by user '{}'",
/** 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; }