Search in sources :

Example 6 with KubernetesServerImpl

use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl in project devspaces-images by redhat-developer.

the class KubernetesMachinesCacheTest method shouldUpdateServerStatus.

@Test
public void shouldUpdateServerStatus() throws Exception {
    // given
    RuntimeIdentity runtimeId = runtimeStates[0].getRuntimeId();
    // when
    machineCache.updateServerStatus(runtimeId, machines[0].getName(), "server1", ServerStatus.RUNNING);
    // then
    KubernetesServerImpl fetchedServer = machineCache.getServer(runtimeId, "machine1", "server1");
    assertEquals(fetchedServer.getStatus(), ServerStatus.RUNNING);
}
Also used : RuntimeIdentity(org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity) KubernetesServerImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl) Test(org.testng.annotations.Test)

Example 7 with KubernetesServerImpl

use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl in project devspaces-images by redhat-developer.

the class KubernetesMachinesCacheTest method shouldGetServer.

@Test
public void shouldGetServer() throws Exception {
    // given
    RuntimeIdentity runtimeId = runtimeStates[0].getRuntimeId();
    KubernetesMachineImpl machine = machines[0];
    Entry<String, KubernetesServerImpl> serverToFetch = machine.getServers().entrySet().iterator().next();
    // when
    KubernetesServerImpl fetched = machineCache.getServer(runtimeId, machine.getName(), serverToFetch.getKey());
    // then
    assertEquals(fetched, serverToFetch.getValue());
}
Also used : RuntimeIdentity(org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity) KubernetesServerImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl) KubernetesMachineImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl) Test(org.testng.annotations.Test)

Example 8 with KubernetesServerImpl

use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl in project devspaces-images by redhat-developer.

the class KubernetesMachinesCacheTest method shouldUpdateMachineStatusServerStatus.

@Test
public void shouldUpdateMachineStatusServerStatus() throws Exception {
    // given
    RuntimeIdentity runtimeId = runtimeStates[0].getRuntimeId();
    // when
    machineCache.updateServerStatus(runtimeId, machines[0].getName(), "server1", ServerStatus.RUNNING);
    // then
    KubernetesServerImpl fetchedServer = machineCache.getServer(runtimeId, "machine1", "server1");
    assertEquals(fetchedServer.getStatus(), ServerStatus.RUNNING);
}
Also used : RuntimeIdentity(org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity) KubernetesServerImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl) Test(org.testng.annotations.Test)

Example 9 with KubernetesServerImpl

use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl in project che-server by eclipse-che.

the class JpaKubernetesMachineCache method doUpdateServerStatus.

@Transactional(rollbackOn = { RuntimeException.class, InfrastructureException.class })
protected boolean doUpdateServerStatus(RuntimeIdentity runtimeIdentity, String machineName, String serverName, ServerStatus status) throws InfrastructureException {
    EntityManager entityManager = managerProvider.get();
    KubernetesServerImpl server = getServer(runtimeIdentity, machineName, serverName);
    if (server.getStatus() != status) {
        server.setStatus(status);
        entityManager.flush();
        return true;
    }
    return false;
}
Also used : EntityManager(javax.persistence.EntityManager) KubernetesServerImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl) Transactional(com.google.inject.persist.Transactional)

Example 10 with KubernetesServerImpl

use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl in project devspaces-images by redhat-developer.

the class JpaKubernetesMachineCache method getServer.

@Transactional(rollbackOn = InfrastructureException.class)
@Override
public KubernetesServerImpl getServer(RuntimeIdentity runtimeIdentity, String machineName, String serverName) throws InfrastructureException {
    try {
        String workspaceId = runtimeIdentity.getWorkspaceId();
        KubernetesServerImpl server = managerProvider.get().find(KubernetesServerImpl.class, new ServerId(workspaceId, machineName, serverName));
        if (server == null) {
            throw new InfrastructureException(format("Server with name '%s' was not found", serverName));
        }
        return server;
    } catch (RuntimeException e) {
        throw new InfrastructureException(e.getMessage(), e);
    }
}
Also used : KubernetesServerImpl(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl) ServerId(org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl.ServerId) InfrastructureException(org.eclipse.che.api.workspace.server.spi.InfrastructureException) Transactional(com.google.inject.persist.Transactional)

Aggregations

KubernetesServerImpl (org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl)10 RuntimeIdentity (org.eclipse.che.api.core.model.workspace.runtime.RuntimeIdentity)6 Test (org.testng.annotations.Test)6 Transactional (com.google.inject.persist.Transactional)4 EntityManager (javax.persistence.EntityManager)2 InfrastructureException (org.eclipse.che.api.workspace.server.spi.InfrastructureException)2 KubernetesMachineImpl (org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesMachineImpl)2 ServerId (org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl.ServerId)2