Skip to content

Commit

Permalink
Make snapshots binaries removal asynchornous
Browse files Browse the repository at this point in the history
  • Loading branch information
Yevhenii Voevodin committed Dec 16, 2016
1 parent fda7a00 commit 806febf
Show file tree
Hide file tree
Showing 11 changed files with 968 additions and 923 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.eclipse.che.api.core.model.machine.Machine;
import org.eclipse.che.api.core.model.workspace.WorkspaceRuntime;
import org.eclipse.che.api.core.model.workspace.WorkspaceStatus;
import org.eclipse.che.api.core.rest.shared.dto.Link;
import org.eclipse.che.api.core.rest.shared.dto.LinkParameter;
import org.eclipse.che.api.machine.shared.Constants;
Expand Down Expand Up @@ -396,7 +397,9 @@ protected void onMessageReceived(WorkspaceStatusEvent statusEvent) {
break;

case RUNNING:
onWorkspaceStarted(workspaceId);
if (statusEvent.getPrevStatus() == WorkspaceStatus.STARTING) {
onWorkspaceStarted(workspaceId);
}
break;

case ERROR:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.google.inject.Provider;
import com.google.web.bindery.event.shared.EventBus;

import org.eclipse.che.api.core.model.workspace.WorkspaceStatus;
import org.eclipse.che.api.core.rest.shared.dto.Link;
import org.eclipse.che.api.core.rest.shared.dto.LinkParameter;
import org.eclipse.che.api.machine.shared.dto.MachineConfigDto;
Expand Down Expand Up @@ -262,6 +263,7 @@ public void onWorkspaceStartingTest() throws Exception {
@Test
public void onWorkspaceStartedTest() throws Exception {
when(workspaceStatusEvent.getEventType()).thenReturn(RUNNING);
when(workspaceStatusEvent.getPrevStatus()).thenReturn(WorkspaceStatus.STARTING);

workspaceEventsHandler.trackWorkspaceEvents(workspace, callback);
workspaceEventsHandler.workspaceStatusSubscriptionHandler.onMessageReceived(workspaceStatusEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,128 @@
*******************************************************************************/
package org.eclipse.che.api.workspace.shared.dto.event;

import org.eclipse.che.api.core.model.workspace.WorkspaceStatus;
import org.eclipse.che.api.core.notification.EventOrigin;
import org.eclipse.che.commons.annotation.Nullable;
import org.eclipse.che.dto.shared.DTO;

/**
* Describes changes of state of a workspace.
* Describes workspace status changes.
*
* @author Alexander Garagatyi
* @author Yevhenii Voevodin
*/
@EventOrigin("workspace")
@DTO
public interface WorkspaceStatusEvent {

/** Defines event type for workspace status event changes. */
enum EventType {
STARTING, RUNNING, STOPPING, STOPPED, ERROR, SNAPSHOT_CREATING, SNAPSHOT_CREATED, SNAPSHOT_CREATION_ERROR

/**
* Published after workspace status is changed to STARTING.
* If {@link WorkspaceStatusEvent#getEventType()} returns this value, then
* the value of {@link WorkspaceStatusEvent#getPrevStatus()} is
* {@link WorkspaceStatus#STOPPED}.
*
* @see WorkspaceStatus#STARTING
*/
STARTING,

/**
* Published after workspace status becomes {@link WorkspaceStatus#RUNNING}.
* If {@link WorkspaceStatusEvent#getEventType()} returns this value, then
* the value of {@link WorkspaceStatusEvent#getPrevStatus()} is
* either {@link WorkspaceStatus#STARTING} or {@link WorkspaceStatus#SNAPSHOTTING}.
*
* @see WorkspaceStatus#RUNNING
*/
RUNNING,

/**
* Published after workspace status becomes {@link WorkspaceStatus#STOPPING}.
* If {@link WorkspaceStatusEvent#getEventType()} returns this value, then
* the value of {@link WorkspaceStatusEvent#getPrevStatus()} is {@link WorkspaceStatus#RUNNING}.
*
* @see WorkspaceStatus#STOPPING
*/
STOPPING,

/**
* Published after workspace is successfully stopped.
* If {@link WorkspaceStatusEvent#getEventType()} returns this value, then
* the value of {@link WorkspaceStatusEvent#getPrevStatus()} is {@link WorkspaceStatus#STOPPING}.
*
* @see WorkspaceStatus#STOPPED
*/
STOPPED,

/**
* Published after workspace status becomes {@link WorkspaceStatus#SNAPSHOTTING}.
* If {@link WorkspaceStatusEvent#getEventType()} returns this value, then
* the value of {@link WorkspaceStatusEvent#getPrevStatus()} is {@link WorkspaceStatus#RUNNING}.
*
* @see WorkspaceStatus#SNAPSHOTTING
*/
SNAPSHOT_CREATING,

/**
* Published after workspace snapshot is successfully created.
* If {@link WorkspaceStatusEvent#getEventType()} returns this value, then
* the value of {@link WorkspaceStatusEvent#getPrevStatus()} is {@link WorkspaceStatus#SNAPSHOTTING}.
*
* @see WorkspaceStatus#SNAPSHOTTING
*/
SNAPSHOT_CREATED,

/**
* Published after workspace snapshot is not created due to occurred error.
* If {@link WorkspaceStatusEvent#getEventType()} returns this value, then
* the value of {@link WorkspaceStatusEvent#getPrevStatus()} is {@link WorkspaceStatus#SNAPSHOTTING}.
*
* @see WorkspaceStatus#SNAPSHOTTING
*/
SNAPSHOT_CREATION_ERROR,

/**
* Published when any error occurs.
* If {@link WorkspaceStatusEvent#getEventType()} returns this value, then
* the value returned by {@link WorkspaceStatusEvent#getPrevStatus()} is
* one of the values above, never null.
*/
ERROR
}

/** Returns the type of this event. */
EventType getEventType();

void setEventType(EventType eventType);

WorkspaceStatusEvent withEventType(EventType eventType);

/**
* Returns previous workspace status.
*
* @see WorkspaceStatus for more information about certain values
*/
WorkspaceStatus getPrevStatus();

void setPrevStatus(WorkspaceStatus status);

WorkspaceStatusEvent withPrevStatus(WorkspaceStatus status);

/** The id of the workspace to which this event belongs to . */
String getWorkspaceId();

void setWorkspaceId(String machineId);

WorkspaceStatusEvent withWorkspaceId(String machineId);

/**
* Returns an error message value if and only if the type of this event is
* either {@link EventType#ERROR} or {@link EventType#SNAPSHOT_CREATION_ERROR}.
*/
@Nullable
String getError();

void setError(String error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,7 @@ public void stopMachine(String workspaceId, String machineId) throws NotFoundExc
* @throws ServerException
* if another error occurs
*/
public SnapshotImpl saveSnapshot(String namespace,
String workspaceId,
public SnapshotImpl saveSnapshot(String workspaceId,
String machineId) throws ServerException,
NotFoundException {
EnvironmentHolder environmentHolder;
Expand Down

0 comments on commit 806febf

Please sign in to comment.