Skip to content

Commit

Permalink
first class migrated
Browse files Browse the repository at this point in the history
  • Loading branch information
farshad68 committed Jan 24, 2025
1 parent 33624f1 commit bdb8e48
Show file tree
Hide file tree
Showing 16 changed files with 663 additions and 189 deletions.
19 changes: 19 additions & 0 deletions platform-controller/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<artifactId>platform-controller</artifactId>
<packaging>jar</packaging>

<properties>
<kubernetes-client.version>18.0.0</kubernetes-client.version>
</properties>
<!-- LICENSE -->
<licenses>
<license>
Expand Down Expand Up @@ -105,6 +108,22 @@
<version>2.8.8</version>
</dependency>

<!-- ~~~~~~~~~~~~~~~~~~~ Kubernetes ~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- java api-->
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java-api</artifactId>
<version>${kubernetes-client.version}</version>
</dependency>
<!-- java client -->
<dependency>
<groupId>io.kubernetes</groupId>
<artifactId>client-java</artifactId>
<version>${kubernetes-client.version}</version>
</dependency>

<!-- ~~~~~~~~~~~~~~~~~~~ End Kubernetes ~~~~~~~~~~~~~~~~~~~~~~ -->

<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
import org.hobbit.controller.data.ExperimentStatus;
import org.hobbit.controller.data.ExperimentStatus.States;
import org.hobbit.controller.data.SetupHardwareInformation;
import org.hobbit.controller.docker.ClusterManager;
import org.hobbit.controller.docker.ContainerManager;
import org.hobbit.controller.interfaces.ClusterManager;
import org.hobbit.controller.interfaces.ContainerManager;
import org.hobbit.controller.docker.MetaDataFactory;
import org.hobbit.controller.execute.ExperimentAbortTimerTask;
import org.hobbit.controller.utils.RabbitMQConnector;
Expand Down Expand Up @@ -599,7 +599,7 @@ public void notifyTermination(String containerId, long exitCode) {
// send a message using sendToCmdQueue(command,
// data) comprising a command that indicates that a
// container terminated and the container name
String containerName = controller.containerManager.getContainerName(containerId);
String containerName = controller.containerManager.getContainerPodName(containerId);
if (containerName != null) {
try {
controller.sendToCmdQueue(Constants.HOBBIT_SESSION_ID_FOR_BROADCASTS,
Expand Down Expand Up @@ -663,7 +663,7 @@ public void systemOrBenchmarkReady(boolean systemReportedReady, String sessionId
* daemon
*/
private void startBenchmark_unsecured() throws IOException {
String containerName = controller.containerManager.getContainerName(experimentStatus.getSystemContainer());
String containerName = controller.containerManager.getContainerPodName(experimentStatus.getSystemContainer());
if (containerName == null) {
throw new IOException(
"Couldn't derive container name of the system container for sending start message to the benchmark.");
Expand Down Expand Up @@ -799,7 +799,7 @@ public void setController(PlatformController controller) {
/**
* Add reported error to the experiment result model if the experiment with the
* given session is still running.
*
*
* @param sessionId the session ID of the container that reported the
* error
* @param errorData the data of the reported error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
import org.apache.jena.vocabulary.RDF;
import org.hobbit.controller.analyze.ExperimentAnalyzer;
import org.hobbit.controller.data.ExperimentConfiguration;
import org.hobbit.controller.docker.ClusterManager;
import org.hobbit.controller.interfaces.ClusterManager;
import org.hobbit.controller.docker.ClusterManagerImpl;
import org.hobbit.controller.docker.ContainerManager;
import org.hobbit.controller.interfaces.ContainerManager;
import org.hobbit.controller.docker.ContainerManagerImpl;
import org.hobbit.controller.docker.ContainerStateObserver;
import org.hobbit.controller.docker.ContainerStateObserverImpl;
Expand Down Expand Up @@ -498,7 +498,7 @@ public void receiveCommand(byte command, byte[] data, String sessionId, AMQP.Bas
* @return the name of the created container
*/
private String createContainer(StartCommandData data) {
String parentId = containerManager.getContainerId(data.parent);
String parentId = containerManager.getContainerPodId(data.parent);
if ((parentId == null) && (CONTAINER_PARENT_CHECK)) {
LOGGER.error("Couldn't create container because the parent \"{}\" is not known.", data.parent);
return null;
Expand All @@ -515,7 +515,7 @@ private String createContainer(StartCommandData data) {
if (containerId == null) {
return null;
} else {
return containerManager.getContainerName(containerId);
return containerManager.getContainerPodName(containerId);
}
}

Expand All @@ -525,7 +525,7 @@ private String createContainer(StartCommandData data) {
* @param containerName name of the container that should be stopped
*/
public void stopContainer(String containerName) {
String containerId = containerManager.getContainerId(containerName);
String containerId = containerManager.getContainerPodId(containerName);
if (containerId != null) {
containerManager.removeContainer(containerId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.stream.Stream;

import org.hobbit.controller.interfaces.ClusterManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import java.util.stream.Collectors;

import org.hobbit.controller.gitlab.GitlabControllerImpl;
import org.hobbit.controller.interfaces.ClusterManager;
import org.hobbit.controller.interfaces.ContainerManager;
import org.hobbit.controller.utils.Waiting;
import org.hobbit.core.Constants;
import org.slf4j.Logger;
Expand Down Expand Up @@ -561,8 +563,8 @@ public String startContainer(String imageName, String[] command) {
return startContainer(imageName, null, "", command);
}

public String startContainer(String imageName, String type, String parent) {
return startContainer(imageName, type, parent, null);
public String startContainer(String imageName, String type, String parentId) {
return startContainer(imageName, type, parentId, null);
}

@Override
Expand Down Expand Up @@ -618,7 +620,7 @@ public String startContainer(String imageName, String containerType, String pare
@Override
public void removeContainer(String serviceName) {
try {
Long exitCode = getContainerExitCode(serviceName);
Long exitCode = getContainerPodExitCode(serviceName);
if (DEPLOY_ENV.equals(DEPLOY_ENV_DEVELOP)) {
LOGGER.info("Will not remove container {}. " + "Development mode is enabled.", serviceName);
} else if (DEPLOY_ENV.equals(DEPLOY_ENV_TESTING) && (exitCode != null && exitCode != 0)) {
Expand Down Expand Up @@ -681,7 +683,7 @@ public void removeParentAndChildren(String parent) {
}
}

@Override
//@Override
public Service getContainerInfo(String serviceName) throws InterruptedException, DockerException {
if (serviceName == null) {
return null;
Expand All @@ -705,7 +707,7 @@ public List<Service> getContainers(Service.Criteria criteria) {
}

@Override
public Long getContainerExitCode(String serviceName) throws DockerException, InterruptedException {
public Long getContainerPodExitCode(String serviceName) throws DockerException, InterruptedException {
if (getContainerInfo(serviceName) == null) {
LOGGER.warn(
"Couldn't get the exit code for container {}. Service doesn't exist. Assuming it was stopped by the platform.",
Expand Down Expand Up @@ -740,13 +742,13 @@ public Long getContainerExitCode(String serviceName) throws DockerException, Int

@Deprecated
@Override
public String getContainerId(String name) {
public String getContainerPodId(String name) {
return name;
}

@Deprecated
@Override
public String getContainerName(String containerId) {
public String getContainerPodName(String containerId) {
return containerId;
}

Expand Down Expand Up @@ -778,7 +780,7 @@ public ContainerStats getStats(String containerId) {
return stats;
}

@Override
//@Override
public String getContainerType(String containerId) {
Service container = null;
try {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.util.Timer;
import java.util.TimerTask;

import io.kubernetes.client.openapi.ApiException;
import org.hobbit.controller.interfaces.ContainerManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -94,7 +96,7 @@ public void run() {
}
for (String id : containerIds) {
try {
Long exitStatus = manager.getContainerExitCode(id);
Long exitStatus = manager.getContainerPodExitCode(id);

if (exitStatus != null) {
// notify all callbacks
Expand All @@ -106,7 +108,7 @@ public void run() {
}
}
}
} catch (DockerException | InterruptedException e) {
} catch (DockerException | ApiException | InterruptedException e ) {
LOGGER.error("Couldn't get the status of container " + id
+ ". It will be ignored during this run but will be checked again during the next run.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import javax.ws.rs.core.UriBuilder;

import org.apache.commons.io.IOUtils;
import org.hobbit.controller.interfaces.ContainerManager;
import org.hobbit.core.Constants;
import org.hobbit.core.data.usage.CpuStats;
import org.hobbit.core.data.usage.DiskStats;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.hobbit.controller.docker;
package org.hobbit.controller.interfaces;

import com.spotify.docker.client.exceptions.DockerException;
import com.spotify.docker.client.messages.Info;
Expand Down
Loading

0 comments on commit bdb8e48

Please sign in to comment.