Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not fetch runtimes when getting list of all workspaces #3557

Merged
merged 13 commits into from
Jan 10, 2017
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public List<WorkspaceImpl> getWorkspaces(String user) throws ServerException {
requireNonNull(user, "Required non-null user id");
final List<WorkspaceImpl> workspaces = workspaceDao.getWorkspaces(user);
for (WorkspaceImpl workspace : workspaces) {
normalizeState(workspace);
workspace.setStatus(runtimes.getStatus(workspace.getId()));
}
return workspaces;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,23 @@ public Map<String, WorkspaceState> getWorkspaces() {
return new HashMap<>(workspaces);
}

/**
* Return status of the workspace
*
* @param workspaceId
* ID of requested workspace
* @return workspace status
*/
public WorkspaceStatus getStatus(String workspaceId) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests

try (@SuppressWarnings("unused") CloseableLock l = locks.acquireReadLock(workspaceId)) {
final WorkspaceState state = workspaces.get(workspaceId);
if (state == null) {
return WorkspaceStatus.STOPPED;
}
return state.status;
}
}

private MessageConsumer<MachineLogMessage> getEnvironmentLogger(String workspaceId) throws ServerException {
WebsocketMessageConsumer<MachineLogMessage> envMessageConsumer =
new WebsocketMessageConsumer<>(format(ENVIRONMENT_OUTPUT_CHANNEL_TEMPLATE, workspaceId));
Expand Down