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

Make snapshots binaries removal asynchronous #3405

Merged
merged 1 commit into from Dec 16, 2016
Merged

Conversation

voievodin
Copy link
Contributor

What does this PR do?

  • Makes snapshots binaries removal asynchronous(while metadata removal is still synchronous)
  • Publishes WorkspaceStatusEvent.RUNNING after workspace changes status from SNAPSHOTTING back to RUNNING
  • Reaches WorkspaceStatusEvent with previous workspace status field
  • Introduces small fixes & improvements to workspace codebase

What issues does this PR fix or reference?

Resolves #3314 & resolves #3258.

@@ -401,7 +402,9 @@ protected void onMessageReceived(WorkspaceStatusEvent statusEvent) {
break;

case RUNNING:
onWorkspaceStarted(workspaceId);
if (statusEvent.getPrevStatus() == WorkspaceStatus.STARTING) {
Copy link
Contributor

Choose a reason for hiding this comment

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

explain this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

RUNNING may be received twice, e.g.

1. STOPPED -> STARTING -> RUNNING 
2. RUNNING -> SNAPSHOTTING -> RUNNING

onWorkspaceStarted(workspaceId) obviously related to the 1st case

@@ -825,6 +710,14 @@ void checkWorkspaceIsRunning(WorkspaceImpl workspace, String operation) throws C
}
}

private void removeTmpWorkspace(Workspace workspace) {
Copy link
Contributor

Choose a reason for hiding this comment

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

removeTmpWorkspaceQuietly?

@codenvy-ci
Copy link

Build # 1337 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/1337/ to view the results.

@@ -59,6 +60,7 @@ public WorkspaceImpl create(WorkspaceImpl workspace) throws ConflictException, S
requireNonNull(workspace, "Required non-null workspace");
try {
doCreate(workspace);
eventService.publish(new WorkspaceCreatedEvent(workspace));
} catch (DuplicateKeyException dkEx) {

Choose a reason for hiding this comment

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

Are you sure we should do that in DAO? In that case it will reach subscribers even before manager ends execution of method that called DAO.

public void snapshot(String workspaceId) throws NotFoundException,
ConflictException,
ServerException {
try (@SuppressWarnings("unused") CloseableLock l = locks.acquireWriteLock(workspaceId)) {

Choose a reason for hiding this comment

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

I didn't know how to suppress that, thanks for tip!

LOG.info("Shutdown running workspaces, workspaces to shutdown '{}'", idsToStop.size());
ExecutorService executor =
Executors.newFixedThreadPool(2 * Runtime.getRuntime().availableProcessors(),
new ThreadFactoryBuilder().setNameFormat("StopEnvironmentsPool-%d")

Choose a reason for hiding this comment

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

Please catch uncaught exceptions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exceptions won't occur, task logs all the exceptiions see below.

verify(runtimes).publishWorkspaceEvent(EventType.ERROR,
workspace.getId(),
e.getLocalizedMessage());
DtoFactory.newDto(WorkspaceStatusEvent.class)

Choose a reason for hiding this comment

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

You probably forgot verification here

@codenvy-ci
Copy link

@codenvy-ci
Copy link

@@ -633,8 +614,11 @@ void performAsyncStart(WorkspaceImpl workspace,
workspace.getAttributes().put(UPDATED_ATTRIBUTE_NAME, Long.toString(currentTimeMillis()));
workspaceDao.update(workspace);
final String env = firstNonNull(envName, workspace.getConfig().getDefaultEnv());

// barrier, safely doesn't allow to start the workspace twice
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain about which barrier here is described?

private final StripedLocks stripedLocks;
private final CheEnvironmentEngine environmentEngine;
private final Map<String, WorkspaceState> workspaces;
private final EventService eventsService;
Copy link
Member

Choose a reason for hiding this comment

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

Why it is better to name variable as eventsService here?

@voievodin voievodin force-pushed the fix_status_publishing branch 2 times, most recently from 7741032 to 92a90c2 Compare December 16, 2016 15:37
@benoitf benoitf changed the title Make snapshots binaries removal asynchornous Make snapshots binaries removal asynchronous Dec 16, 2016
@Nullable Boolean restore) throws NotFoundException,
ServerException,
ConflictException {
@Nullable String envName,
Copy link
Member

Choose a reason for hiding this comment

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

fix formatting here

@voievodin voievodin merged commit bf2f1bc into master Dec 16, 2016
@voievodin voievodin deleted the fix_status_publishing branch December 16, 2016 16:27
@codenvy-ci
Copy link

JPinkney pushed a commit to JPinkney/che that referenced this pull request Aug 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants