-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds system graceful stop tracking events
3 new events are added, they are: * STOPPING_SERVICE - published before service is stopped * SERVICE_ITEM_STOPPED - published each time service item(like workspace) is stopped * SERVICE_STOPPED - published after service is stopped
- Loading branch information
Yevhenii Voevodin
committed
Feb 7, 2017
1 parent
ee95f2c
commit f2bcdfb
Showing
22 changed files
with
982 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...tem-shared/src/main/java/org/eclipse/che/api/system/shared/dto/SystemServiceEventDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2017 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.api.system.shared.dto; | ||
|
||
import org.eclipse.che.dto.shared.DTO; | ||
|
||
/** | ||
* DTO for system service events. | ||
* | ||
* @author Yevhenii Voevodin | ||
*/ | ||
@DTO | ||
public interface SystemServiceEventDto extends SystemEventDto { | ||
|
||
/** | ||
* Returns the name of the service described by this event. | ||
*/ | ||
String getService(); | ||
|
||
void setService(String service); | ||
|
||
SystemServiceEventDto withService(String service); | ||
} |
56 changes: 56 additions & 0 deletions
56
...src/main/java/org/eclipse/che/api/system/shared/dto/SystemServiceItemStoppedEventDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2017 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.api.system.shared.dto; | ||
|
||
import org.eclipse.che.api.system.shared.event.EventType; | ||
import org.eclipse.che.commons.annotation.Nullable; | ||
import org.eclipse.che.dto.shared.DTO; | ||
|
||
/** | ||
* See {@link EventType#SERVICE_ITEM_STOPPED} for details. | ||
* | ||
* @author Yevhenii Voevodin | ||
*/ | ||
@DTO | ||
public interface SystemServiceItemStoppedEventDto extends SystemServiceEventDto { | ||
|
||
/** | ||
* Returns an item for which this event is published(like workspace id). | ||
*/ | ||
String getItem(); | ||
|
||
void setItem(String item); | ||
|
||
SystemServiceItemStoppedEventDto withItem(String item); | ||
|
||
/** | ||
* Returns an amount of items currently stopped, it's either present | ||
* with {@link #getTotal()} or missing at all(null is returned). | ||
*/ | ||
@Nullable | ||
Integer getCurrent(); | ||
|
||
void setCurrent(Integer current); | ||
|
||
SystemServiceItemStoppedEventDto withCurrent(Integer current); | ||
|
||
/** | ||
* Returns total count of items which had not been stopped before | ||
* service shutdown was called. It's either present with {@link #getCurrent()} | ||
* or missing at all(null is returned). | ||
*/ | ||
@Nullable | ||
Integer getTotal(); | ||
|
||
void setTotal(Integer total); | ||
|
||
SystemServiceItemStoppedEventDto withTotal(Integer total); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...main/java/org/eclipse/che/api/system/shared/event/service/StoppingSystemServiceEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2017 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.api.system.shared.event.service; | ||
|
||
import org.eclipse.che.api.system.shared.event.EventType; | ||
|
||
/** | ||
* See {@link EventType#STOPPING_SERVICE} description. | ||
* | ||
* @author Yevhenii Voevodin | ||
*/ | ||
public class StoppingSystemServiceEvent extends SystemServiceEvent { | ||
|
||
public StoppingSystemServiceEvent(String serviceName) { | ||
super(serviceName); | ||
} | ||
|
||
@Override | ||
public EventType getType() { | ||
return EventType.STOPPING_SERVICE; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...red/src/main/java/org/eclipse/che/api/system/shared/event/service/SystemServiceEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2017 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.api.system.shared.event.service; | ||
|
||
import org.eclipse.che.api.system.shared.event.SystemEvent; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* The base class for system service events. | ||
* | ||
* @author Yevhenii Voevodin | ||
*/ | ||
public abstract class SystemServiceEvent implements SystemEvent { | ||
|
||
protected final String serviceName; | ||
|
||
protected SystemServiceEvent(String serviceName) { | ||
this.serviceName = Objects.requireNonNull(serviceName, "Service name required"); | ||
} | ||
|
||
public String getServiceName() { | ||
return serviceName; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (!(obj instanceof SystemServiceEvent)) { | ||
return false; | ||
} | ||
final SystemServiceEvent that = (SystemServiceEvent)obj; | ||
return Objects.equals(getType(), that.getType()) | ||
&& Objects.equals(serviceName, that.serviceName); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int hash = 17; | ||
hash = 31 * hash + Objects.hashCode(getType()); | ||
hash = 31 * hash + Objects.hashCode(serviceName); | ||
return hash; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getClass().getSimpleName() + "{eventType='" + getType() + "', serviceName=" + serviceName + "'}"; | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
...n/java/org/eclipse/che/api/system/shared/event/service/SystemServiceItemStoppedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2017 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.api.system.shared.event.service; | ||
|
||
import org.eclipse.che.api.system.shared.event.EventType; | ||
import org.eclipse.che.commons.annotation.Nullable; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* See {@link EventType#SERVICE_ITEM_STOPPED} description. | ||
* | ||
* @author Yevhenii Voevodin | ||
*/ | ||
public class SystemServiceItemStoppedEvent extends SystemServiceEvent { | ||
|
||
private final String item; | ||
|
||
private Integer total; | ||
private Integer current; | ||
|
||
public SystemServiceItemStoppedEvent(String serviceName, String item) { | ||
super(serviceName); | ||
this.item = Objects.requireNonNull(item, "Item required"); | ||
} | ||
|
||
public SystemServiceItemStoppedEvent(String serviceName, | ||
String item, | ||
@Nullable Integer current, | ||
@Nullable Integer total) { | ||
this(serviceName, item); | ||
this.current = current; | ||
this.total = total; | ||
} | ||
|
||
@Override | ||
public EventType getType() { | ||
return EventType.SERVICE_ITEM_STOPPED; | ||
} | ||
|
||
public String getItem() { | ||
return item; | ||
} | ||
|
||
@Nullable | ||
public Integer getTotal() { | ||
return total; | ||
} | ||
|
||
@Nullable | ||
public Integer getCurrent() { | ||
return current; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (!(obj instanceof SystemServiceItemStoppedEvent)) { | ||
return false; | ||
} | ||
final SystemServiceItemStoppedEvent that = (SystemServiceItemStoppedEvent)obj; | ||
return super.equals(that) | ||
&& item.equals(that.item) | ||
&& Objects.equals(total, that.total) | ||
&& Objects.equals(current, that.current); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int hash = 7; | ||
hash = 31 * hash + super.hashCode(); | ||
hash = 31 * hash + item.hashCode(); | ||
hash = 31 * hash + Objects.hashCode(total); | ||
hash = 31 * hash + Objects.hashCode(current); | ||
return hash; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "SystemServiceItemStoppedEvent{" + | ||
"item='" + item + '\'' + | ||
", total=" + total + | ||
", current=" + current + | ||
", eventType='" + getType() + '\'' + | ||
", service='" + getServiceName() + | ||
"\'}"; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
.../main/java/org/eclipse/che/api/system/shared/event/service/SystemServiceStoppedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2017 Codenvy, S.A. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.api.system.shared.event.service; | ||
|
||
import org.eclipse.che.api.system.shared.event.EventType; | ||
|
||
/** | ||
* See {@link EventType#SERVICE_STOPPED} description. | ||
* | ||
* @author Yevhenii Voevodin | ||
*/ | ||
public class SystemServiceStoppedEvent extends SystemServiceEvent { | ||
|
||
public SystemServiceStoppedEvent(String serviceName) { | ||
super(serviceName); | ||
} | ||
|
||
@Override | ||
public EventType getType() { | ||
return EventType.SERVICE_STOPPED; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.