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())); } }
private Workspace doUpdate(String id, Workspace update) throws BadRequestException, ConflictException, NotFoundException, ServerException { try { return workspaceManager.updateWorkspace(id, update); } catch (ValidationException x) { throw new BadRequestException(x.getMessage()); } }
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())); } }
@Override public WorkspaceImpl updateWorkspace(String id, Workspace update) throws ConflictException, ServerException, NotFoundException, ValidationException { checkMaxEnvironmentRam(update.getConfig()); WorkspaceImpl workspace = this.getWorkspace(id); String accountId = workspace.getAccount().getId(); // Workspace must not be updated while the manager checks it's resources to allow start try (@SuppressWarnings("unused") Unlocker u = resourcesLocks.lock(accountId)) { return super.updateWorkspace(id, update); } }