org.eclipse.che.core
che-core-api-workspace
diff --git a/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftClientFactory.java b/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftClientFactory.java
index 089ace392f..821e0ae232 100644
--- a/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftClientFactory.java
+++ b/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftClientFactory.java
@@ -24,7 +24,6 @@ import io.fabric8.openshift.client.OpenShiftConfigBuilder;
import io.fabric8.openshift.client.internal.OpenShiftOAuthInterceptor;
import java.io.IOException;
import java.net.URL;
-import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
@@ -226,15 +225,6 @@ public class OpenShiftClientFactory extends KubernetesClientFactory {
return createOC(buildConfig(getDefaultConfig(), null));
}
- @PreDestroy
- private void cleanup() {
- try {
- doCleanup();
- } catch (RuntimeException ex) {
- LOG.error(ex.getMessage());
- }
- }
-
/** Decorates the {@link DefaultOpenShiftClient} so that it can not be closed from the outside. */
private static class UnclosableOpenShiftClient extends DefaultOpenShiftClient {
diff --git a/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftInfraModule.java b/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftInfraModule.java
index 018fdfdc37..caef4c0ebc 100644
--- a/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftInfraModule.java
+++ b/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/OpenShiftInfraModule.java
@@ -18,6 +18,7 @@ import com.google.inject.TypeLiteral;
import com.google.inject.assistedinject.FactoryModuleBuilder;
import com.google.inject.multibindings.MapBinder;
import com.google.inject.multibindings.Multibinder;
+import org.eclipse.che.api.system.server.ServiceTermination;
import org.eclipse.che.api.workspace.server.spi.RuntimeInfrastructure;
import org.eclipse.che.api.workspace.server.spi.environment.InternalEnvironmentFactory;
import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiExternalEnvVarProvider;
@@ -25,6 +26,7 @@ import org.eclipse.che.api.workspace.server.spi.provision.env.CheApiInternalEnvV
import org.eclipse.che.api.workspace.server.spi.provision.env.EnvVarProvider;
import org.eclipse.che.workspace.infrastructure.docker.environment.dockerimage.DockerImageEnvironment;
import org.eclipse.che.workspace.infrastructure.docker.environment.dockerimage.DockerImageEnvironmentFactory;
+import org.eclipse.che.workspace.infrastructure.kubernetes.KubernetesClientTermination;
import org.eclipse.che.workspace.infrastructure.kubernetes.bootstrapper.KubernetesBootstrapperFactory;
import org.eclipse.che.workspace.infrastructure.kubernetes.cache.KubernetesMachineCache;
import org.eclipse.che.workspace.infrastructure.kubernetes.cache.KubernetesRuntimeStateCache;
@@ -87,5 +89,9 @@ public class OpenShiftInfraModule extends AbstractModule {
bind(KubernetesRuntimeStateCache.class).to(JpaKubernetesRuntimeStateCache.class);
bind(KubernetesMachineCache.class).to(JpaKubernetesMachineCache.class);
+
+ Multibinder.newSetBinder(binder(), ServiceTermination.class)
+ .addBinding()
+ .to(KubernetesClientTermination.class);
}
}
diff --git a/multiuser/permission/che-multiuser-permission-system/src/test/java/org/eclipse/che/multiuser/permission/system/SystemServicePermissionsFilterTest.java b/multiuser/permission/che-multiuser-permission-system/src/test/java/org/eclipse/che/multiuser/permission/system/SystemServicePermissionsFilterTest.java
index d3b2003ae6..0db4d27475 100644
--- a/multiuser/permission/che-multiuser-permission-system/src/test/java/org/eclipse/che/multiuser/permission/system/SystemServicePermissionsFilterTest.java
+++ b/multiuser/permission/che-multiuser-permission-system/src/test/java/org/eclipse/che/multiuser/permission/system/SystemServicePermissionsFilterTest.java
@@ -16,6 +16,7 @@ import static java.util.Arrays.asList;
import static org.everrest.assured.JettyHttpServer.ADMIN_USER_NAME;
import static org.everrest.assured.JettyHttpServer.ADMIN_USER_PASSWORD;
import static org.everrest.assured.JettyHttpServer.SECURE_PATH;
+import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyObject;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.never;
@@ -92,7 +93,7 @@ public class SystemServicePermissionsFilterTest {
.then()
.statusCode(204);
- verify(systemService).stop();
+ verify(systemService).stop(anyBoolean());
}
@Test
@@ -107,7 +108,7 @@ public class SystemServicePermissionsFilterTest {
.then()
.statusCode(403);
- verify(systemService, never()).stop();
+ verify(systemService, never()).stop(anyBoolean());
}
@Test
diff --git a/wsmaster/che-core-api-system-shared/src/main/java/org/eclipse/che/api/system/shared/event/EventType.java b/wsmaster/che-core-api-system-shared/src/main/java/org/eclipse/che/api/system/shared/event/EventType.java
index cf2a5bce7b..e5a0d9d242 100644
--- a/wsmaster/che-core-api-system-shared/src/main/java/org/eclipse/che/api/system/shared/event/EventType.java
+++ b/wsmaster/che-core-api-system-shared/src/main/java/org/eclipse/che/api/system/shared/event/EventType.java
@@ -30,15 +30,37 @@ public enum EventType {
*/
STOPPING_SERVICE,
+ /**
+ * Published when system is starting to suspend a service. This is the first event published for a
+ * certain service.
+ *
+ *
+ * SUSPENDING_SERVICE -> (0..N)SERVICE_ITEM_SUSPENDED -> SERVICE_SUSPENDED
+ *
+ */
+ SUSPENDING_SERVICE,
+
/**
* Published after service item is stopped. Events of such type are published between {@link
* #STOPPING_SERVICE} and {@link #SERVICE_STOPPED} events.
*/
SERVICE_ITEM_STOPPED,
+ /**
+ * Published after service item is suspended. Events of such type are published between {@link
+ * #SUSPENDING_SERVICE} and {@link #SERVICE_SUSPENDED} events.
+ */
+ SERVICE_ITEM_SUSPENDED,
+
/**
* Published when shutting down of a service is finished. The last event in the chain for a
* certain service.
*/
- SERVICE_STOPPED
+ SERVICE_STOPPED,
+
+ /**
+ * Published when suspending a service is finished. The last event in the chain for a certain
+ * service.
+ */
+ SERVICE_SUSPENDED
}
diff --git a/wsmaster/che-core-api-system-shared/src/main/java/org/eclipse/che/api/system/shared/event/service/SuspendingSystemServiceEvent.java b/wsmaster/che-core-api-system-shared/src/main/java/org/eclipse/che/api/system/shared/event/service/SuspendingSystemServiceEvent.java
new file mode 100644
index 0000000000..6d9d3b9d7b
--- /dev/null
+++ b/wsmaster/che-core-api-system-shared/src/main/java/org/eclipse/che/api/system/shared/event/service/SuspendingSystemServiceEvent.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2012-2018 Red Hat, Inc.
+ * 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:
+ * Red Hat, Inc. - 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#SUSPENDING_SERVICE} description.
+ *
+ * @author Max Shaposhnyk
+ */
+public class SuspendingSystemServiceEvent extends SystemServiceEvent {
+
+ public SuspendingSystemServiceEvent(String serviceName) {
+ super(serviceName);
+ }
+
+ @Override
+ public EventType getType() {
+ return EventType.SUSPENDING_SERVICE;
+ }
+}
diff --git a/wsmaster/che-core-api-system-shared/src/main/java/org/eclipse/che/api/system/shared/event/service/SystemServiceItemSuspendedEvent.java b/wsmaster/che-core-api-system-shared/src/main/java/org/eclipse/che/api/system/shared/event/service/SystemServiceItemSuspendedEvent.java
new file mode 100644
index 0000000000..ed22fdd773
--- /dev/null
+++ b/wsmaster/che-core-api-system-shared/src/main/java/org/eclipse/che/api/system/shared/event/service/SystemServiceItemSuspendedEvent.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2012-2018 Red Hat, Inc.
+ * 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:
+ * Red Hat, Inc. - initial API and implementation
+ */
+package org.eclipse.che.api.system.shared.event.service;
+
+import java.util.Objects;
+import org.eclipse.che.api.system.shared.event.EventType;
+import org.eclipse.che.commons.annotation.Nullable;
+
+/**
+ * See {@link EventType#SERVICE_ITEM_SUSPENDED} description.
+ *
+ * @author Max Shaposhnyk
+ */
+public class SystemServiceItemSuspendedEvent extends SystemServiceEvent {
+
+ private final String item;
+
+ private Integer total;
+ private Integer current;
+
+ public SystemServiceItemSuspendedEvent(String serviceName, String item) {
+ super(serviceName);
+ this.item = Objects.requireNonNull(item, "Item required");
+ }
+
+ public SystemServiceItemSuspendedEvent(
+ 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_SUSPENDED;
+ }
+
+ 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 SystemServiceItemSuspendedEvent)) {
+ return false;
+ }
+ final SystemServiceItemSuspendedEvent that = (SystemServiceItemSuspendedEvent) 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 "SystemServiceItemSuspendedEvent{"
+ + "item='"
+ + item
+ + '\''
+ + ", total="
+ + total
+ + ", current="
+ + current
+ + ", eventType='"
+ + getType()
+ + '\''
+ + ", service='"
+ + getServiceName()
+ + "\'}";
+ }
+}
diff --git a/wsmaster/che-core-api-system-shared/src/main/java/org/eclipse/che/api/system/shared/event/service/SystemServiceSuspendedEvent.java b/wsmaster/che-core-api-system-shared/src/main/java/org/eclipse/che/api/system/shared/event/service/SystemServiceSuspendedEvent.java
new file mode 100644
index 0000000000..23919e11db
--- /dev/null
+++ b/wsmaster/che-core-api-system-shared/src/main/java/org/eclipse/che/api/system/shared/event/service/SystemServiceSuspendedEvent.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2012-2018 Red Hat, Inc.
+ * 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:
+ * Red Hat, Inc. - 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_SUSPENDED} description.
+ *
+ * @author Max Shaposhnyk
+ */
+public class SystemServiceSuspendedEvent extends SystemServiceEvent {
+
+ public SystemServiceSuspendedEvent(String serviceName) {
+ super(serviceName);
+ }
+
+ @Override
+ public EventType getType() {
+ return EventType.SERVICE_SUSPENDED;
+ }
+}
diff --git a/wsmaster/che-core-api-system/pom.xml b/wsmaster/che-core-api-system/pom.xml
index cc6fa0c364..3120dabb1e 100644
--- a/wsmaster/che-core-api-system/pom.xml
+++ b/wsmaster/che-core-api-system/pom.xml
@@ -74,6 +74,10 @@
org.eclipse.che.core
che-core-commons-annotations
+