public class PlatformController extends org.hobbit.core.components.AbstractCommandReceivingComponent implements ContainerTerminationCallback, ExperimentAnalyzer
| Modifier and Type | Field and Description |
|---|---|
protected Timer |
challengePublishTimer
Timer used to trigger publishing of challenges
|
protected ClusterManager |
clusterManager |
private static boolean |
CONTAINER_PARENT_CHECK |
private static String |
CONTAINER_PARENT_CHECK_ENV_KEY |
protected ContainerManager |
containerManager
A manager for Docker containers.
|
protected ContainerStateObserver |
containerObserver
The observer of docker containers.
|
protected com.rabbitmq.client.Channel |
controller2Analysis
RabbitMQ channel between front end and platform controller.
|
private static String |
DEPLOY_ENV |
private static String |
DEPLOY_ENV_DEVELOP |
private static String |
DEPLOY_ENV_TESTING |
protected ExperimentManager |
expManager |
protected com.rabbitmq.client.Channel |
frontEnd2Controller
RabbitMQ channel between front end and platform controller.
|
protected FrontEndApiHandler |
frontEndApiHandler
The handler for requests coming from the front end.
|
private com.google.gson.Gson |
gson
Threadsafe JSON parser.
|
protected ClusterHealthChecker |
healthChecker
Health checker used to make sure that the cluster has the preconfigured
hardware.
|
protected ImageManager |
imageManager
Manager of benchmark and system images.
|
private long |
lastIdTime
Last experiment id that has been used.
|
private static org.slf4j.Logger |
LOGGER |
static String |
PLATFORM_VERSION
The current version of the platform.
|
static long |
PUBLISH_CHALLENGES |
protected ExperimentQueue |
queue
The queue containing experiments that are waiting for their execution.
|
private static String |
RABBIT_MQ_EXPERIMENTS_HOST_NAME_KEY |
protected String |
rabbitMQExperimentsHostName |
protected ResourceInformationCollector |
resInfoCollector |
protected org.hobbit.storage.client.StorageServiceClient |
storage |
private Semaphore |
terminationMutex
A simple mutex that is used to wait for a termination signal for the
controller.
|
| Constructor and Description |
|---|
PlatformController() |
| Modifier and Type | Method and Description |
|---|---|
protected String |
addExperimentToQueue(String benchmarkUri,
String systemUri,
String userName,
String serializedBenchParams,
String challengUri,
String challengTaskUri,
Calendar executionDate)
Adds a new experiment with the given benchmark, system and benchmark
parameter to the queue.
|
void |
analyzeExperiment(String uri)
Runs further analysis based on the experiment results of the given URI.
|
protected void |
checkRepeatableChallenges() |
void |
close() |
private void |
closeChallenge(String challengeUri)
Closes the challenge with the given URI by adding the "closed" triple to its
graph and inserting the configured experiments into the queue.
|
protected static boolean |
copyChallengeToPublicResultGraph(org.hobbit.storage.client.StorageServiceClient storage,
String challengeUri)
Copies the challenge from challenge definition graph to public graph.
|
private String |
createContainer(org.hobbit.core.data.StartCommandData data)
Creates and starts a container based on the given
StartCommandData
instance. |
private org.apache.jena.rdf.model.Model |
createExpModelForChallengeTask(org.apache.jena.rdf.model.Model model,
String challengeTaskUri,
String systemUri) |
private org.hobbit.core.data.StartCommandData |
deserializeStartCommandData(byte[] data) |
private org.hobbit.core.data.StopCommandData |
deserializeStopCommandData(byte[] data) |
private void |
executeChallengeExperiments(String challengeUri)
Inserts the configured experiments of a challenge into the queue.
|
private String |
generateExperimentId()
Generates a unique experiment Id based on the current time stamp and the last
Id (
lastIdTime) that has been created. |
static String |
generateExperimentUri(String id)
Generates an experiment URI using the given id and the experiment URI
namespace defined by
Constants.EXPERIMENT_URI_NS. |
protected org.apache.jena.rdf.model.Model |
getChallengeFromUri(String challengeUri,
String graphUri)
Retrieves model for the given challenge from the given graph (or without
selecting a certain graph if the graphUri is
null). |
private List<ExperimentConfiguration> |
getChallengeTasksFromUri(String challengeUri) |
private org.hobbit.core.data.status.ControllerStatus |
getStatus(String userName)
Creates a status object summarizing the current status of this controller.
|
protected void |
handleCmd(byte[] bytes,
String replyTo)
The controller overrides the super method because it does not need to check
for the leading hobbit id and delegates the command handling to the
receiveCommand(byte, byte[], String, String) method. |
void |
handleFrontEndCmd(byte[] bytes,
String replyTo,
com.rabbitmq.client.AMQP.BasicProperties replyProperties) |
ImageManager |
imageManager() |
void |
init() |
void |
notifyTermination(String containerId,
int exitCode)
This method is called if the container with the given container Id
terminated.
|
String |
rabbitMQHostName() |
private static String |
readVersion() |
void |
receiveCommand(byte command,
byte[] data)
Deprecated.
Not used inside the controller. Use
receiveCommand(byte, byte[], String, String) instead. |
void |
receiveCommand(byte command,
byte[] data,
String sessionId,
String replyTo)
Handles incoming command request from the hobbit command queue.
|
protected static void |
republishChallenges(org.hobbit.storage.client.StorageServiceClient storage,
ExperimentQueue queue,
ExperimentAnalyzer analyzer) |
void |
run() |
protected static void |
scheduleDateOfNextExecution(org.hobbit.storage.client.StorageServiceClient storage,
String challengeUri,
Calendar now)
Schedules the date of next execution for a repeatable challenge, or closes
it.
|
protected void |
sendToCmdQueue(byte command)
Deprecated.
The
PlatformController should use
#sendToCmdQueue(String, byte, byte[], BasicProperties) |
protected void |
sendToCmdQueue(byte command,
byte[] data)
Deprecated.
The
PlatformController should use
#sendToCmdQueue(String, byte, byte[], BasicProperties) |
protected void |
sendToCmdQueue(byte command,
byte[] data,
com.rabbitmq.client.AMQP.BasicProperties props)
Deprecated.
The
PlatformController should use
#sendToCmdQueue(String, byte, byte[], BasicProperties) |
protected void |
sendToCmdQueue(String address,
byte command,
byte[] data,
com.rabbitmq.client.AMQP.BasicProperties props)
Sends the given command to the command queue with the given data appended and
using the given properties.
|
void |
stopContainer(String containerName)
Stops the container with the given container name.
|
org.hobbit.storage.client.StorageServiceClient |
storage() |
private void |
switchCmdToExpRabbit()
This method closes the command queue and its handling and reopens it on the
RabbitMQ broker which will be used for experiments.
|
addCommandHeaderId, createContainer, createContainerprivate static final org.slf4j.Logger LOGGER
public static final String PLATFORM_VERSION
private static final String DEPLOY_ENV
private static final String DEPLOY_ENV_TESTING
private static final String DEPLOY_ENV_DEVELOP
private static final String CONTAINER_PARENT_CHECK_ENV_KEY
private static final boolean CONTAINER_PARENT_CHECK
private static final String RABBIT_MQ_EXPERIMENTS_HOST_NAME_KEY
public static final long PUBLISH_CHALLENGES
protected com.rabbitmq.client.Channel frontEnd2Controller
protected FrontEndApiHandler frontEndApiHandler
protected com.rabbitmq.client.Channel controller2Analysis
protected ContainerManager containerManager
protected ContainerStateObserver containerObserver
protected ExperimentQueue queue
protected ClusterHealthChecker healthChecker
private Semaphore terminationMutex
private com.google.gson.Gson gson
protected ImageManager imageManager
private long lastIdTime
protected org.hobbit.storage.client.StorageServiceClient storage
protected ExperimentManager expManager
protected ResourceInformationCollector resInfoCollector
protected ClusterManager clusterManager
protected Timer challengePublishTimer
protected String rabbitMQExperimentsHostName
public void init()
throws Exception
init in interface org.hobbit.core.components.Componentinit in class org.hobbit.core.components.AbstractCommandReceivingComponentExceptionprivate void switchCmdToExpRabbit()
throws Exception
Exceptionpublic void receiveCommand(byte command,
byte[] data,
String sessionId,
String replyTo)
Commands handled by this method:
Commands.DOCKER_CONTAINER_STARTCommands.DOCKER_CONTAINER_STOPcommand - command to be executeddata - byte-encoded supplementary json for the command
0 - start container 1 - stop container Data format for each
command: Start container:private org.hobbit.core.data.StopCommandData deserializeStopCommandData(byte[] data)
private org.hobbit.core.data.StartCommandData deserializeStartCommandData(byte[] data)
private String createContainer(org.hobbit.core.data.StartCommandData data)
StartCommandData
instance.data - the data needed to start the containerpublic void stopContainer(String containerName)
stopContainer in class org.hobbit.core.components.AbstractCommandReceivingComponentcontainerName - name of the container that should be stoppedpublic void run()
throws Exception
run in interface org.hobbit.core.components.ComponentExceptionpublic void notifyTermination(String containerId, int exitCode)
ContainerTerminationCallbacknotifyTermination in interface ContainerTerminationCallbackcontainerId - the id of the container that terminatedexitCode - the exit code of the containerpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class org.hobbit.core.components.AbstractCommandReceivingComponentIOExceptionpublic void analyzeExperiment(String uri) throws IOException
ExperimentAnalyzeranalyzeExperiment in interface ExperimentAnalyzeruri - the URI of the experiment which should be enhanced with
further analysisIOExceptionprotected void sendToCmdQueue(String address, byte command, byte[] data, com.rabbitmq.client.AMQP.BasicProperties props) throws IOException
address - address for the messagecommand - the command that should be sentdata - data that should be appended to the commandprops - properties that should be used for the messageIOExceptionprotected void handleCmd(byte[] bytes,
String replyTo)
receiveCommand(byte, byte[], String, String) method.handleCmd in class org.hobbit.core.components.AbstractCommandReceivingComponentpublic void handleFrontEndCmd(byte[] bytes,
String replyTo,
com.rabbitmq.client.AMQP.BasicProperties replyProperties)
protected org.apache.jena.rdf.model.Model getChallengeFromUri(String challengeUri, String graphUri)
null).challengeUri - the URI for which the model should be retrievedgraphUri - the URI from which the data should be retrieved or null if
all graphs should be taken into account.private List<ExperimentConfiguration> getChallengeTasksFromUri(String challengeUri)
private void executeChallengeExperiments(String challengeUri)
challengeUri - the URI of the challengeprotected static void scheduleDateOfNextExecution(org.hobbit.storage.client.StorageServiceClient storage,
String challengeUri,
Calendar now)
storage - storagechallengeUri - challenge URInow - time to use as current when schedulingprotected static boolean copyChallengeToPublicResultGraph(org.hobbit.storage.client.StorageServiceClient storage,
String challengeUri)
storage - storagechallengeUri - challenge URIprivate void closeChallenge(String challengeUri)
challengeUri - the URI of the challenge that should be closedprotected void checkRepeatableChallenges()
protected static void republishChallenges(org.hobbit.storage.client.StorageServiceClient storage,
ExperimentQueue queue,
ExperimentAnalyzer analyzer)
private org.apache.jena.rdf.model.Model createExpModelForChallengeTask(org.apache.jena.rdf.model.Model model,
String challengeTaskUri,
String systemUri)
protected String addExperimentToQueue(String benchmarkUri, String systemUri, String userName, String serializedBenchParams, String challengUri, String challengTaskUri, Calendar executionDate)
benchmarkUri - the URI of the benchmarksystemUri - the URI of the systemuserName - the name of the user who requested the creation of the experimentserializedBenchParams - the serialized benchmark parametersexecutionDate - the date at which this experiment should be executed as part of a
challenge. Should be set to null if it is not part of
a challenge.private org.hobbit.core.data.status.ControllerStatus getStatus(String userName)
private String generateExperimentId()
lastIdTime) that has been created.public static String generateExperimentUri(String id)
Constants.EXPERIMENT_URI_NS.id - the id of the experimentpublic ImageManager imageManager()
public org.hobbit.storage.client.StorageServiceClient storage()
public String rabbitMQHostName()
@Deprecated public void receiveCommand(byte command, byte[] data)
receiveCommand(byte, byte[], String, String) instead.receiveCommand in interface org.hobbit.core.components.CommandReceivingComponent@Deprecated protected void sendToCmdQueue(byte command) throws IOException
PlatformController should use
#sendToCmdQueue(String, byte, byte[], BasicProperties)sendToCmdQueue in class org.hobbit.core.components.AbstractCommandReceivingComponentIOException@Deprecated protected void sendToCmdQueue(byte command, byte[] data) throws IOException
PlatformController should use
#sendToCmdQueue(String, byte, byte[], BasicProperties)sendToCmdQueue in class org.hobbit.core.components.AbstractCommandReceivingComponentIOException@Deprecated protected void sendToCmdQueue(byte command, byte[] data, com.rabbitmq.client.AMQP.BasicProperties props) throws IOException
PlatformController should use
#sendToCmdQueue(String, byte, byte[], BasicProperties)sendToCmdQueue in class org.hobbit.core.components.AbstractCommandReceivingComponentIOExceptionprivate static String readVersion()
Copyright © 2017–2018. All rights reserved.