use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl in project che-server by eclipse-che.
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());
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl in project che-server by eclipse-che.
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);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl in project che-server by eclipse-che.
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);
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl in project che-server by eclipse-che.
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);
}
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.model.KubernetesServerImpl in project devspaces-images by redhat-developer.
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;
}
Aggregations