Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • lennart.thiesen/de.ugoe.cs.rwm.mocci
  • rwm/de.ugoe.cs.rwm.mocci
2 results
Show changes
Commits on Source (56)
Showing
with 908 additions and 876 deletions
image: gradle:alpine
image: gradle:4.10.3-alpine
stages:
- build
- test
- pages
- deploy
variables:
......@@ -14,8 +15,8 @@ before_script:
build:
stage: build
script:
- mv src/test/resources/martserver-plugins ~/martserver-plugins/
- gradle build
- export VERSION=SNAPSHOT
- gradle assemble
- gradle updateSiteZip
artifacts:
paths:
......@@ -23,25 +24,28 @@ build:
- de.ugoe.cs.rwm.mocci.model.edit/build/libs/*.jar
- de.ugoe.cs.rwm.mocci.model/build/updatesite.zip
expire_in: 1 week
test:
stage: test
script:
- mv src/test/resources/martserver-plugins ~/martserver-plugins/
- gradle check
- export VERSION=SNAPSHOT
- mv src/test/resources/martserver-plugins ~/martserver-plugins/
- gradle check
- gradle jacocoRootReport
- cat build/reports/jacoco/jacocoRootReport/html/index.html
artifacts:
paths:
- build/reports/
- config/html/
- build/reports/
- config/html/
pages:
stage: deploy
stage: pages
script:
- export VERSION=SNAPSHOT
- mkdir public
- mv config/html/* public
- mv de.ugoe.cs.rwm.mocci.model/build/libs/*.jar public/model
- mv de.ugoe.cs.rwm.mocci.model/build/updatesite.zip public/model
- mv de.ugoe.cs.rwm.mocci.model.edit/build/libs/*.jar public/edit
- mv de.ugoe.cs.rwm.mocci.model/build/libs/*.jar public
- mv de.ugoe.cs.rwm.mocci.model/build/updatesite.zip public
artifacts:
paths:
- public
......@@ -52,9 +56,13 @@ pages:
upload:
stage: deploy
script:
- gradle upload
- export VERSION=${CI_COMMIT_TAG}
- echo $VERSION
- gradle upload
only:
- master
- tags
except:
- branches
after_script:
- echo "End CI"
......
# MOCCI
[![build status](https://gitlab.gwdg.de/rwm/de.ugoe.cs.rwm.mocci/badges/master/pipeline.svg)](https://gitlab.gwdg.de/rwm/de.ugoe.cs.rwm.mocci/commits/master)
Mocci is an extension for the Open Cloud Computing Interface (OCCI) to enable a model-driven management of monitoring instruments in the cloud, as well as storing their results within an OCCI runtime model.
Together with other tools from the OCCI ecosystem it provides a testing and execution environment for self-adaptive systems.
In addition to the getting started and the example scenarios discussed in this document, the main components of MOCCI are represented by the:
1. [Monitoring Extension](https://gitlab.gwdg.de/rwm/de.ugoe.cs.rwm.mocci/tree/master/de.ugoe.cs.rwm.mocci.model)
2. [Monitoring Connector](https://gitlab.gwdg.de/rwm/de.ugoe.cs.rwm.mocci/tree/master/de.ugoe.cs.rwm.mocci.connector)
3. [Monitoring Dummy Connector](https://gitlab.gwdg.de/rwm/de.ugoe.cs.rwm.mocci/tree/master/de.ugoe.cs.rwm.mocci.connector.dummy)
MOCCI is an extension for the [Open Cloud Computing Interface (OCCI)](http://occi-wg.org/about/specification/) to enable a model-driven management of monitoring devices in the cloud, as well as storing their results within an OCCI-compliant runtime model. Together with other tools from the OCCI ecosystem it provides a testing and execution environment for self-adaptive systems with an EMF-based architecture runtime model ([Snapshot in JSON format](./doc/browser.png)). In the following you will find a getting started guide in which a preconfigured VirtualBox image is downloaded to perform example scenarios and an tutorial on how to enrich existing OCCI models with monitoring functionality. Moreover, an introduction to MOCCI's components is provided, as well as links and description on how to integrate MOCCI with other pre-existing tooling from the OCCI ecosystem. The paper submitted to this artifact and the VirtualBox image can be found [here](https://owncloud.gwdg.de/index.php/s/5u2ddnyyNlzecM5) with the password being mocci.
## Getting Started
To getting started with MOCCI we provide a hands on experience in form of a virtualbox image in which everything required is already configured and ready to go.
To get started with MOCCI we provide a hands on experience in form of a VirtualBox image in which everything required is already configured and ready to go.
Alternatively, to manually setup the single components instructions can be found at the end of this document.
### VirtualBox
To get a quick start in the OCCI ecosystem and the MOCCI monitoring extension download the following VM image. This image contains a version of OCCI-Studio with the MoDMaCAO and MOCCI plugins pre-installed.
Moreover, it contains a checked out version of MOCCI and a local version of the MARTserver.
### Download VirtualBox Image
To get a quick start into MOCCI download the VM image (Mocci.ova) located here:
```
https://owncloud.gwdg.de/index.php/s/5u2ddnyyNlzecM5
password: mocci
```
This image contains a version of OCCI-Studio with the MoDMaCAO and MOCCI plugins pre-installed.
Moreover, it contains a checked out version of MOCCI and a local version of the MARTserver using dummy connectors.
After the download has finished, open Virtualbox and import the virtual appliance:
After the download has finished, open VirtualBox and import the virtual appliance:
1. Click on File->Import Appliance...
2. Choose the destination of the downloaded image.
3. Adjust the appliance settings according to your System.
1. For a smooth experience 8Gb Ram, and 2 CPUs are recommended.
4. Press Import.
Next start the virtual machine:
Next start the Virtual Machine:
1. Choose the recently imported VM and press Start.
2. The username, and password are both: mocci
## Step-by-step example scenarios
To test MOCCI, we provide step-by-step instructions for two example scenarios.
### Execute Step-by-step Example Scenarios and Tutorials
To learn the ropes of MOCCI, we provide step-by-step instructions for three example scenarios, which are based on the same initial deployment model.
It is recommended to execute the tutorials and examples in the following order:
1. [Vertical Scaling](doc/vertical.md): This scenario scales a VM up and down according to its CPU utilization.
2. [Horizontal Scaling](doc/horizontal.md): This scenario dynamically adds and releases worker nodes in a hadoop cluster.
1. [Initial Deployment](doc/initial.md): This tutorial demonstrates how to deploy an initial cloud application getting monitored by MOCCI.
2. [Vertical Scaling](doc/vertical.md): This scenario scales a VM in the initial deployment up and down according to its CPU utilization.
3. [Horizontal Scaling](doc/horizontal.md): This scenario dynamically adds and releases worker nodes in the hadoop cluster of the initial deployment.
4. [Sensor Creation](doc/own.md): This tutorial shows how to add sensors to an OCCI model.
*Note:* Please note that the execution of the example scenarios in an distributed environment, e.g., requires access to it as well as connectors implementing how the differen requests should be handled.
Thus, the provided scenarios are based on monitoring data simulated by the [MOCCI connector dummy](https://gitlab.gwdg.de/rwm/de.ugoe.cs.rwm.mocci/tree/master/de.ugoe.cs.rwm.mocci.connector.dummy).
## MOCCI Components, Documentation, and Related Artifacts
MOCCI itself is a monitoring extension that in combination with pre-existing software from the OCCI ecosystem allows for an easy development and testing of self-adaptation engines for cloud systems.
This section provides an overview of MOCCI's components, as well as other tools used to develop and perform the example scenarios.
## OCCI-Studio and MoDMaCAO
### MOCCI (artifact)
MOCCI consists of three main components. The metamodel extension for OCCI, a connector responsible to deploy, configure, and manage arbitrary sensors and monitoring devices in the cloud using configuration management scripts, and a dummy connector simulating user defined monitoring results for test purposes. Descriptions of the single components can be found via the following links:
In addition to the getting started and the example scenarios discussed in this document, the main components of MOCCI are represented by the:
1. [Monitoring Extension](https://gitlab.gwdg.de/rwm/de.ugoe.cs.rwm.mocci/tree/master/de.ugoe.cs.rwm.mocci.model)
2. [Monitoring Connector](https://gitlab.gwdg.de/rwm/de.ugoe.cs.rwm.mocci/tree/master/de.ugoe.cs.rwm.mocci.connector)
3. [Monitoring Dummy Connector](https://gitlab.gwdg.de/rwm/de.ugoe.cs.rwm.mocci/tree/master/de.ugoe.cs.rwm.mocci.connector.dummy)
### OCCI-Studio and MoDMaCAO (pre-existing Software from the OCCI ecosystem)
[OCCI-Studio](https://github.com/occiware/OCCI-Studio) is an IDE providing many convenient tools to develop around OCCI. For example, it provides a model editor, graphically and textually. Moreover, it allows to design OCCI extensions and automatically generate code from it.
In addition to OCCI-Studio the [Model-Driven Configuration Management of Cloud Applications with OCCI (MoDMaCAO)](https://github.com/occiware/MoDMaCAO) extension suite is needed.
[Documentation on how to setup and configure OCCI-Studio](doc/studio.md)
[Documentation on how to setup and configure OCCI-Studio with MOCCI](doc/studio.md)
## MartServer
### MartServer (pre-existing Software from the OCCI ecosystem)
The [MartServer](https://github.com/occiware/MartServer) represents the OCCI interface to which requests are send in order to build and monitor the cloud application.
This server is easy to extend by plugging in connectors created for modeled OCCI extensions.
[Documentation on how to setup and configure the MartServer](doc/openstack.md)
[Documentation on how to setup and configure the MartServer](doc/api.md)
*Note:* Please note that the execution of the example scenarios in an distributed environment requires access and connectors to the cloud.
Thus, the provided scenarios in the getting started VM is only executed based on monitoring data simulated by the [MOCCI connector dummy](https://gitlab.gwdg.de/rwm/de.ugoe.cs.rwm.mocci/tree/master/de.ugoe.cs.rwm.mocci.connector.dummy).
// Apply the java-library plugin to add support for Java Library
apply plugin: 'eclipse'
apply plugin: 'java'
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply plugin: 'maven'
apply plugin: "com.github.psxpaul.execfork"
apply plugin: 'jacoco'
apply plugin: 'com.github.johnrengelman.shadow'
ext {
tocciVersion = '1.0.1'
docciVersion = '1.0.4'
cocciVersion = '1.0.0'
}
subprojects {
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.github.psxpaul:gradle-execfork-plugin:0.1.8"
classpath "com.github.jengelman.gradle.plugins:shadow:4.0.3"
}
}
allprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'maven'
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
repositories {
sourceCompatibility = 1.8
targetCompatibility = 1.8
mavenCentral()
maven {
url "https://nexus.informatik.uni-goettingen.de/content/repositories/thirdparty/"
}
maven {
url "https://nexus.informatik.uni-goettingen.de/content/repositories/rwm/"
}
}
javadoc {
source = sourceSets.main.allJava
classpath = configurations.compile
failOnError = true
}
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.github.psxpaul:gradle-execfork-plugin:0.1.8"
classpath "com.github.jengelman.gradle.plugins:shadow:4.0.3"
}
test {
testLogging.showStandardStreams = true
testLogging {
exceptionFormat = 'full'
}
}
}
sourceSets {
startMartServer {
resources {
srcDir 'src/test/resources'
configure([project(':de.ugoe.cs.rwm.mocci.connector'), project(':de.ugoe.cs.rwm.mocci.connector.dummy'), rootProject]) {
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply plugin: 'jacoco'
checkstyle {
toolVersion = '8.2'
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
configProperties = [
'checkstyle.cache.file': "${buildDir}/checkstyle.cache",
]
ignoreFailures = true
showViolations = true
}
}
}
eclipse.classpath.file.beforeMerged{ classpath -> classpath.entries.clear() }
findbugs {
sourceSets = [sourceSets.main]
ignoreFailures = true
}
// In this section you declare where to find the dependencies of your project
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
//mavenLocal()
mavenCentral()
jcenter()
maven {
url "https://nexus.informatik.uni-goettingen.de/content/repositories/thirdparty/"
tasks.withType(FindBugs) {
reports {
xml.enabled false
html.enabled true
}
}
maven {
url "https://nexus.informatik.uni-goettingen.de/content/repositories/rwm/"
test.finalizedBy jacocoTestReport
jacoco {
toolVersion = "0.8.1"
}
jacocoTestReport {
additionalSourceDirs = files(sourceSets.main.allSource.srcDirs)
sourceDirectories = files(sourceSets.main.allSource.srcDirs)
classDirectories = files(sourceSets.main.output)
reports {
xml.enabled false
csv.enabled false
}
}
}
dependencies {
//Nexus
compile "org.eclipse.uml2:org.eclipse.uml2.uml:4.1.2"
//runtime?
compile "org.eclipse.uml2:org.eclipse.uml2.types:1.1.0"
compile "org.eclipse.uml2:org.eclipse.uml2.common:1.8.2"
compile group: 'org.eclipse.ocl', name: 'pivot', version: '1.3.0'
//occiware
compile group: 'org.eclipse.cmf.occi', name: 'core', version: '1.0.0'
compile group: 'org.eclipse.cmf.occi', name: 'infrastructure', version: '1.0.0'
//own
compile group: 'de.ugoe.cs.rwm', name: 'cocci', version: '1.0.0'
compile group: 'de.ugoe.cs.rwm', name: 'docci', version: '1.0.0'
compile group: 'de.ugoe.cs.rwm', name: 'tocci', version: '1.0.0'
compile group: 'de.ugoe.cs.rwm.mocci', name: 'model', version: '1.0.0'
//compile project(':de.ugoe.cs.rwm.mocci.model')
//modmacao
compile group: 'org.modmacao', name: 'core', version: '1.0.0'
compile group: 'org.modmacao', name: 'placement', version: '1.0.0'
compile group: 'org.modmacao.occi', name: 'platform', version: '1.0.0'
compile group: 'org.modmacao.openstack', name: 'runtime', version: '1.0.0'
compile group: 'org.modmacao.openstack.swe', name: 'runtime', version: '1.0.0'
compile group: 'org.modmacao', name: 'ansible', version: '1.0.0'
//maven
compile group: 'log4j', name: 'log4j', version: '1.2.17'
compile group: 'com.google.guava', name: 'guava', version: '25.1-jre'
compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.11.0'
compile "org.eclipse.core:org.eclipse.core.runtime:3.7.0"
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
compile group: 'com.jcraft', name: 'jsch', version: '0.1.54'
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'de.ugoe.cs.rwm.pog', name: 'model', version: '1.0.0'
compile group: 'de.ugoe.cs.rwm.pcg', name: 'model', version: '1.0.0'
//testImplementation 'junit:junit:4.12'
sourceSets {
startMartServer {
resources {
srcDir 'src/test/resources'
}
}
}
eclipse.classpath.file.beforeMerged { classpath -> classpath.entries.clear() }
dependencies {
//occiware
compile group: 'org.eclipse.cmf.occi', name: 'core', version: '1.0.0'
compile group: 'org.eclipse.cmf.occi', name: 'infrastructure', version: '1.0.0'
compile group: 'org.eclipse.cmf.occi', name: 'crtp', version: '1.0.0'
compile group: 'org.modmacao', name: 'core', version: '1.0.0'
compile group: 'org.modmacao', name: 'placement', version: '1.0.0'
compile group: 'org.modmacao.occi', name: 'platform', version: '1.0.0'
compile group: 'org.modmacao.openstack', name: 'runtime', version: '1.0.1'
compile group: 'org.modmacao.openstack.swe', name: 'runtime', version: '1.0.0'
compile group: 'org.modmacao', name: 'ansible', version: '1.0.1'
compile group: 'org.eclipse.cmf.occi', name: 'docker', version: '1.0.0'
project(':de.ugoe.cs.rwm.mocci.model.edit') {
dependencies {
//own
compile group: 'de.ugoe.cs.rwm.domain', name: 'workload', version: '1.0.1'
compile group: 'de.ugoe.cs.rwm', name: 'cocci', version: cocciVersion
compile group: 'de.ugoe.cs.rwm', name: 'docci', version: docciVersion
compile group: 'de.ugoe.cs.rwm', name: 'tocci', version: tocciVersion
compile group: 'de.ugoe.cs.rwm.pog', name: 'model', version: '1.0.0'
//compile group: 'de.ugoe.cs.rwm.mocci', name: 'model', version: '1.0.0'
compile project(':de.ugoe.cs.rwm.mocci.model')
}
//maven
compile group: 'log4j', name: 'log4j', version: '1.2.17'
compile group: 'com.google.guava', name: 'guava', version: '25.1-jre'
compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.11.0'
compile "org.eclipse.core:org.eclipse.core.runtime:3.7.0"
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
compile group: 'com.jcraft', name: 'jsch', version: '0.1.54'
//Nexus
compile "org.eclipse.uml2:org.eclipse.uml2.uml:4.1.2"
//runtime?
compile "org.eclipse.uml2:org.eclipse.uml2.types:1.1.0"
compile "org.eclipse.uml2:org.eclipse.uml2.common:1.8.2"
compile group: 'org.eclipse.ocl', name: 'pivot', version: '1.3.0'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
project(':de.ugoe.cs.rwm.mocci.connector') {
dependencies {
compile project(':de.ugoe.cs.rwm.mocci.model')
}
project(':de.ugoe.cs.rwm.mocci.model.edit') {
dependencies {
compile project(':de.ugoe.cs.rwm.mocci.model')
}
}
project(':de.ugoe.cs.rwm.mocci.connector.dummy') {
dependencies {
compile project(':de.ugoe.cs.rwm.mocci.model')
}
project(':de.ugoe.cs.rwm.mocci.connector') {
dependencies {
compile project(':de.ugoe.cs.rwm.mocci.model')
}
}
project(':de.ugoe.cs.rwm.mocci.connector.dummy') {
dependencies {
compile project(':de.ugoe.cs.rwm.mocci.model')
}
}
jar {
manifest {
......@@ -128,77 +177,49 @@ jar {
tasks.shadowJar.dependsOn("build")
configurations.all {
// Check for updates every build
//resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
resolutionStrategy.preferProjectModules()
}
javadoc {
source = sourceSets.main.allJava
classpath = configurations.compile
failOnError = true
}
test {
exclude 'de/ugoe/cs/rwm/mocci/live/**'
//exclude 'de/ugoe/cs/rwm/mocci/**'
testLogging.showStandardStreams = true
testLogging {
exceptionFormat = 'full'
}
}
tasks.test.dependsOn("startMartServer")
test.finalizedBy jacocoTestReport
jacoco {
toolVersion = "0.8.1"
}
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination file("${buildDir}/reports/jacoco")
}
}
findbugs {
sourceSets = [sourceSets.main]
ignoreFailures = true
}
checkstyle {
toolVersion = "8.7"
sourceSets = [sourceSets.main]
}
checkstyleMain {
ignoreFailures = true
}
tasks.withType(FindBugs) {
reports {
xml.enabled false
html.enabled true
}
}
task startMartServer(type: com.github.psxpaul.task.JavaExecFork) {
classpath = files("src/test/resources/org.occiware.mart.jetty.jar")
main = 'org.occiware.mart.jetty.MartServer'
standardOutput = "$buildDir/mart.log"
waitForPort = 8080
stopAfter = test
}
task jacocoRootReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
dependsOn = subprojects.test
additionalSourceDirs = files([project(':de.ugoe.cs.rwm.mocci.connector.dummy'), rootProject].sourceSets.main.allSource.srcDirs)
sourceDirectories = files([project(':de.ugoe.cs.rwm.mocci.connector.dummy'), rootProject].sourceSets.main.allSource.srcDirs)
classDirectories = files([project(':de.ugoe.cs.rwm.mocci.connector.dummy'), rootProject].sourceSets.main.output)
executionData = files([project(':de.ugoe.cs.rwm.mocci.connector.dummy'), rootProject].jacocoTestReport.executionData)
reports {
xml.enabled false
csv.enabled false
}
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: "https://nexus.informatik.uni-goettingen.de/content/repositories/rwm/") {
authentication(userName: System.getenv('NEXUSUSER'), password: System.getenv('NEXUSPASSWORD'))
mavenDeployer {
repository(url: "https://nexus.informatik.uni-goettingen.de/content/repositories/rwm/") {
authentication(userName: System.getenv('NEXUSUSER'), password: System.getenv('NEXUSPASSWORD'))
}
if (System.getenv('VERSION') != null) {
pom.version = System.getenv('VERSION')
println "Version is set to: " + System.getenv('VERSION')
}
pom.version = "1.0.0"
pom.artifactId = "mocci"
pom.groupId = "de.ugoe.cs.rwm"
}
pom.version = "SNAPSHOT"
pom.artifactId = "mocci"
pom.groupId = "de.ugoe.cs.rwm"
}
}
}
......@@ -4,9 +4,6 @@
"http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<module name="JavadocPackage"/>
<module name="TreeWalker">
<module name="RegexpSinglelineJava">
<property name="format" value="^\t* "/>
......@@ -16,7 +13,8 @@
<module name="AvoidStarImport">
<property name="excludes" value="java.io,java.util,java.util.concurrent,com.google.common.graph,
org.apache.bcel.classfile,org.mongodb.morphia.annotations,de.ugoe.cs.comfort.data.models,
org.apache.bcel.generic,org.jacoco.core.data,com.github.javaparser.ast.stmt" />
org.apache.bcel.generic,org.jacoco.core.data,com.github.javaparser.ast.stmt,
org.eclipse.cmf.occi.core"/>
</module>
<module name="ConstantName"/>
<module name="EmptyBlock">
......@@ -32,10 +30,6 @@
<property name="allowByTailComment" value="true"/>
<property name="allowNonPrintableEscapes" value="true"/>
</module>
<module name="LineLength">
<property name="max" value="150"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>
<module name="OneTopLevelClass"/>
<module name="NeedBraces"/>
<module name="NoLineWrap"/>
......@@ -48,12 +42,14 @@
<module name="LeftCurly"/>
<module name="RightCurly">
<property name="id" value="RightCurlySame"/>
<property name="tokens" value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_DO"/>
<property name="tokens"
value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_DO"/>
</module>
<module name="RightCurly">
<property name="id" value="RightCurlyAlone"/>
<property name="option" value="alone"/>
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT, INSTANCE_INIT"/>
<property name="tokens"
value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT, INSTANCE_INIT"/>
</module>
<module name="OneStatementPerLine"/>
......
......@@ -4,13 +4,13 @@
<meta charset="utf-8">
<meta name="generator" content="GitLab Pages">
<title>MOCCI Extension Model</title>
<link rel="stylesheet" href="../../style.css">
<link rel="stylesheet" href="./style.css">
</head>
<body>
<center>
<div class="navbar">
<b><a href="./model/de.ugoe.cs.rwm.mocci.model.jar">Download Jar</a></b>
<b><a href="./model/updatesite.zip">Download Eclipse Plugin Archive</a></b>
<b><a href="./de.ugoe.cs.rwm.mocci.model.jar">Download Jar</a></b>
<b><a href="./updatesite.zip">Download Eclipse Plugin Archive</a></b>
</div>
<h1>MOCCI Model Report</h1>
......
# Monitoring Extension Connector Dummy
This component represents the connector dummy for the OCCI monitoring extension. The skeleton for this connector is generated using [OCCI-Studio](https://github.com/occiware/OCCI-Studio).
Hereby, for each element in the monitoring extension a single connector file is present, implementing how to react on different REST requests addressing the corresponding OCCI element.
This dummy is especially useful for testing purposes. Compared to the actual connector, a link to configuration management scripts is not necessary in order to get monitoring data.
# Monitoring Dummy Connector
Each element in the monitoring extension has a single file in the connector implementing how to react on different REST requests addressing the corresponding OCCI element.
This dummy is especially useful for testing purposes. Compared to the [connector](https://gitlab.gwdg.de/rwm/de.ugoe.cs.rwm.mocci/tree/master/de.ugoe.cs.rwm.mocci.connector) for an actual deployment of sensors, a link to configuration management scripts is not necessary in order to get monitoring data.
As soon as a resultprovider is started monitoring results are simulated are passed to the monitorableproperty element of the sensor containing the resultprovider.
The simulated values are easy to adjust and does not require a recompilation of the connector, as only the resultprovider.properties file within the connector has to be modified.
The skeleton for the connector of the OCCI monitoring extension is generated using [OCCI-Studio](https://github.com/occiware/OCCI-Studio).
## Adjusting the Simulation
......@@ -15,12 +14,18 @@ To configure the simulation of monitoring results the following steps have to be
4. Adjust the values to your liking
The adjustment of the file itself is best explained with a small example:
Currently, the file contains the following:
As default the file contains the following:
```
CPU = None,Low,Medium,High,Critical,5000
```
* CPU: Represents the monitorable.property to be adjusted.
* 5000: Represents the interval in which monitoring.results are written.
* None-Critical: Represents the simulated monitoring.results.
Hereby, the following information can be adjusted:
* The first string (CPU): represents the monitorable.property to be adjusted by the simulation.
* The last integer (5000): represents the interval in milliseconds in which a new monitoring.result is written.
* Every string between (None-Critical): represents the values to be filled into the monitoring.result property.
For example, to additionally generate monitoring results for MonitorableProperties having its monitoring.property set to Mem, the file could look like this:
```
CPU = None,Low,Medium,High,Critical,5000
Mem = Save,Alert,10000
```
// Apply the java-library plugin to add support for Java Library
apply plugin : 'eclipse'
apply plugin: 'java'
apply plugin: 'maven'
// In this section you declare where to find the dependencies of your project
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
//mavenLocal()
mavenCentral()
maven {
url "https://nexus.informatik.uni-goettingen.de/content/repositories/thirdparty/"
}
maven {
url "https://nexus.informatik.uni-goettingen.de/content/repositories/rwm/"
}
}
dependencies {
//Require-Bundle: org.eclipse.core.runtime,
// org.eclipse.emf.ecore;visibility:=reexport,
//org.eclipse.ocl.examples.codegen;visibility:=reexport,
//Nexus
compile group: 'org.eclipse.ocl', name: 'pivot', version: '1.3.0'
//compile group: 'de.ugoe.cs.rwm.wocci', name: 'model', version: '1.0.0'
//occiware
compile group: 'org.eclipse.cmf.occi', name: 'core', version: '1.0.0'
compile group: 'org.modmacao.occi', name: 'platform', version: '1.0.0'
compile group: 'org.modmacao', name: 'cm', version: '1.0.0'
compile group: 'org.modmacao.core', name: 'connector', version : '1.0.0'
compile group: 'commons-io', name: 'commons-io', version: '2.6'
//maven
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile group: 'org.eclipse.emf', name: 'org.eclipse.emf.ecore', version: '2.15.0'
compile group: 'org.eclipse.emf', name: 'org.eclipse.emf.ecore', version: '2.15.0'
compile group: 'org.eclipse.emf', name: 'org.eclipse.emf.ecore.xmi', version: '2.15.0'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
sourceSets {
main {
java {
srcDir 'src-gen'
}
srcDir 'src-gen'
}
//output.classesDir = "$workDir/client/program"
}
}
test {
java.srcDir 'src-test'
}
}
processResources {
from("."){
include("plugin.xml")
include("resultprovider.properties")
}
processResources {
from("."){
include("plugin.xml")
include("resultprovider.properties")
}
}
......@@ -70,7 +44,11 @@ uploadArchives {
repository(url: "https://nexus.informatik.uni-goettingen.de/content/repositories/rwm/") {
authentication(userName: System.getenv('NEXUSUSER'), password: System.getenv('NEXUSPASSWORD'))
}
pom.version = "1.0.0"
if (System.getenv('VERSION') != null) {
pom.version = System.getenv('VERSION')
println "Version is set to: " + System.getenv('VERSION')
}
pom.version = "SNAPSHOT"
pom.artifactId = "connector"
pom.groupId = "de.ugoe.cs.rwm.mocci"
}
......
CPU = None,Low,Medium,High,Critical,3000
Mem = None1,Low1,Medium1,High1,Critical1,4000
\ No newline at end of file
CPU=None,Low,Medium,High,Critical,3000
Mem=None1,Low1,Medium1,High1,Critical1,4000
MecoTaskResultWhile=false,false,false,true,2000
MecoTaskResultForEach='var0,var1,var2,var3,var4,var5,var6','var10,var11,var12,var13,var14,var15,var16','var20,var21,var22,var23,var24,var25,var26',2000
CResult=qa,qa,qa,picking,picking,3000
\ No newline at end of file
package de.ugoe.cs.rwm.mocci.connector;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.cmf.occi.core.Link;
import org.eclipse.cmf.occi.core.MixinBase;
import org.modmacao.cm.ConfigurationManagementTool;
import org.modmacao.cm.ansible.AnsibleCMTool;
import org.modmacao.occi.platform.Component;
import org.modmacao.occi.platform.Status;
public class ComponentManager {
private Component comp;
public ComponentManager(Component comp) {
this.comp = comp;
}
public void undeploy() {
switch(comp.getOcciComponentState().getValue()) {
case Status.ACTIVE_VALUE:
comp.stop();
comp.setOcciComponentState(Status.UNDEPLOYED);
break;
case Status.INACTIVE_VALUE:
comp.setOcciComponentState(Status.UNDEPLOYED);
break;
case Status.DEPLOYED_VALUE:
comp.setOcciComponentState(Status.UNDEPLOYED);
break;
case Status.ERROR_VALUE:
comp.setOcciComponentState(Status.UNDEPLOYED);
break;
default:
break;
}
}
// End of user code
// Start of user code Publisher_Kind_deploy_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: deploy
* - title:
*/
public void deploy()
{
int status = -1;
// Component State Machine.
switch(comp.getOcciComponentState().getValue()) {
case Status.UNDEPLOYED_VALUE:
comp.setOcciComponentState(Status.DEPLOYED);
break;
default:
break;
}
}
// End of user code
// Start of user code Publisher_Kind_configure_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: configure
* - title:
*/
public void configure()
{
int status = -1;
// Component State Machine.
switch(comp.getOcciComponentState().getValue()) {
case Status.DEPLOYED_VALUE:
comp.setOcciComponentState(Status.INACTIVE);
break;
default:
break;
}
}
// End of user code
// Start of user code Publisher_Kind_Start_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: start
* - title: Start the application.
*/
public void start()
{
int status = -1;
// Component State Machine.
switch(comp.getOcciComponentState().getValue()) {
case Status.INACTIVE_VALUE:
comp.setOcciComponentState(Status.ACTIVE);
break;
case Status.UNDEPLOYED_VALUE:
comp.setOcciComponentState(Status.ERROR);
break;
default:
break;
}
}
// End of user code
// Start of user code Publisher_Kind_Stop_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: stop
* - title: Stop the application.
*/
public void stop()
{
int status = -1;
// Component State Machine.
switch(comp.getOcciComponentState().getValue()) {
case Status.ACTIVE_VALUE:
comp.setOcciComponentState(Status.INACTIVE);
break;
default:
break;
}
}
// End of user code
private boolean assertCompsStatusEquals(List<Component> components, Status status) {
for (Component component: components) {
if (component.getOcciComponentState().getValue() != status.getValue()) {
return false;
}
}
return true;
}
}
\ No newline at end of file
/**
* Copyright (c) 2016-2017 Inria
*
*
* 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:
* - Philippe Merle <philippe.merle@inria.fr>
* - Faiez Zalila <faiez.zalila@inria.fr>
*
* Generated at Thu Jan 03 13:17:39 CET 2019 from platform:/resource/monitoring/model/monitoring.occie by org.eclipse.cmf.occi.core.gen.connector
*/
package de.ugoe.cs.rwm.mocci.connector;
import monitoring.Dataprocessor;
package de.ugoe.cs.rwm.mocci.connector;
/**
* Connector EFactory for the OCCI extension:
* - name: monitoring
* - scheme: http://schemas.ugoe.cs.rwm/monitoring#
* Connector EFactory for the OCCI extension: - name: monitoring - scheme:
* http://schemas.ugoe.cs.rwm/monitoring#
*/
public class ConnectorFactory extends monitoring.impl.MonitoringFactoryImpl
{
public class ConnectorFactory extends monitoring.impl.MonitoringFactoryImpl {
/**
* EFactory method for OCCI kind:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring#
* - term: sensor
* - title: Sensor Component
* EFactory method for OCCI kind: - scheme:
* http://schemas.ugoe.cs.rwm/monitoring# - term: sensor - title: Sensor
* Component
*/
@Override
public monitoring.Sensor createSensor() {
......@@ -35,10 +31,9 @@ public class ConnectorFactory extends monitoring.impl.MonitoringFactoryImpl
}
/**
* EFactory method for OCCI kind:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring#
* - term: datagatherer
* - title: DataGatherer Resource
* EFactory method for OCCI kind: - scheme:
* http://schemas.ugoe.cs.rwm/monitoring# - term: datagatherer - title:
* DataGatherer Resource
*/
@Override
public monitoring.Datagatherer createDatagatherer() {
......@@ -46,10 +41,9 @@ public class ConnectorFactory extends monitoring.impl.MonitoringFactoryImpl
}
/**
* EFactory method for OCCI kind:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring#
* - term: processor
* - title: Processor Resource
* EFactory method for OCCI kind: - scheme:
* http://schemas.ugoe.cs.rwm/monitoring# - term: processor - title: Processor
* Resource
*/
@Override
public monitoring.Dataprocessor createDataprocessor() {
......@@ -57,10 +51,9 @@ public class ConnectorFactory extends monitoring.impl.MonitoringFactoryImpl
}
/**
* EFactory method for OCCI kind:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring#
* - term: publisher
* - title: Publisher Resource
* EFactory method for OCCI kind: - scheme:
* http://schemas.ugoe.cs.rwm/monitoring# - term: publisher - title: Publisher
* Resource
*/
@Override
public monitoring.Resultprovider createResultprovider() {
......@@ -68,22 +61,19 @@ public class ConnectorFactory extends monitoring.impl.MonitoringFactoryImpl
}
/**
* EFactory method for OCCI kind:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring#
* - term: martpublisher
* - title: MartPublisher Mixin
* EFactory method for OCCI kind: - scheme:
* http://schemas.ugoe.cs.rwm/monitoring# - term: martpublisher - title:
* MartPublisher Mixin
*/
@Override
public monitoring.Occiresultprovider createOcciresultprovider() {
return new OcciresultproviderConnector();
}
/**
* EFactory method for OCCI kind:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring#
* - term: monitoringproperty
* - title: MonitoringProperty Component
* EFactory method for OCCI kind: - scheme:
* http://schemas.ugoe.cs.rwm/monitoring# - term: monitoringproperty - title:
* MonitoringProperty Component
*/
@Override
public monitoring.Monitorableproperty createMonitorableproperty() {
......
/**
* Copyright (c) 2016-2017 Inria
*
*
* 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:
* - Philippe Merle <philippe.merle@inria.fr>
* - Faiez Zalila <faiez.zalila@inria.fr>
*
* Generated at Wed Dec 19 10:30:40 CET 2018 from platform:/resource/monitoring/model/monitoring.occie by org.eclipse.cmf.occi.core.gen.connector
*/
package de.ugoe.cs.rwm.mocci.connector;
import org.modmacao.occi.platform.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Connector implementation for the OCCI kind:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring#
* - term: datagatherer
* - title: DataGatherer Resource
* Connector implementation for the OCCI kind: - scheme:
* http://schemas.ugoe.cs.rwm/monitoring# - term: datagatherer - title:
* DataGatherer Resource
*/
public class DatagathererConnector extends monitoring.impl.DatagathererImpl
{
public class DatagathererConnector extends monitoring.impl.DatagathererImpl {
/**
* Initialize the logger.
*/
......@@ -36,8 +34,7 @@ public class DatagathererConnector extends monitoring.impl.DatagathererImpl
/**
* Constructs a datagatherer connector.
*/
DatagathererConnector()
{
DatagathererConnector() {
LOGGER.debug("Constructor called on " + this);
// TODO: Implement this constructor.
}
......@@ -45,14 +42,13 @@ public class DatagathererConnector extends monitoring.impl.DatagathererImpl
//
// OCCI CRUD callback operations.
//
// Start of user code DatagathererocciCreate
/**
* Called when this Datagatherer instance is completely created.
*/
@Override
public void occiCreate()
{
public void occiCreate() {
LOGGER.debug("occiCreate() called on " + this);
// TODO: Implement this callback or remove this method.
}
......@@ -63,8 +59,7 @@ public class DatagathererConnector extends monitoring.impl.DatagathererImpl
* Called when this Datagatherer instance must be retrieved.
*/
@Override
public void occiRetrieve()
{
public void occiRetrieve() {
LOGGER.debug("occiRetrieve() called on " + this);
// TODO: Implement this callback or remove this method.
}
......@@ -75,8 +70,7 @@ public class DatagathererConnector extends monitoring.impl.DatagathererImpl
* Called when this Datagatherer instance is completely updated.
*/
@Override
public void occiUpdate()
{
public void occiUpdate() {
LOGGER.debug("occiUpdate() called on " + this);
// TODO: Implement this callback or remove this method.
}
......@@ -87,8 +81,7 @@ public class DatagathererConnector extends monitoring.impl.DatagathererImpl
* Called when this Datagatherer instance will be deleted.
*/
@Override
public void occiDelete()
{
public void occiDelete() {
LOGGER.debug("occiDelete() called on " + this);
// TODO: Implement this callback or remove this method.
}
......@@ -100,80 +93,116 @@ public class DatagathererConnector extends monitoring.impl.DatagathererImpl
// Start of user code Datagatherer_Kind_configure_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: configure
* - title:
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: configure
* - title:
*/
@Override
public void configure()
{
public void configure() {
LOGGER.debug("Action configure() called on " + this);
switch (this.getOcciComponentState().getValue()) {
// TODO: Implement how to configure this datagatherer.
case Status.DEPLOYED_VALUE:
this.setOcciComponentState(Status.INACTIVE);
break;
default:
break;
}
}
// End of user code
// Start of user code Datagatherer_Kind_deploy_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: deploy
* - title:
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: deploy -
* title:
*/
@Override
public void deploy()
{
public void deploy() {
LOGGER.debug("Action deploy() called on " + this);
switch (this.getOcciComponentState().getValue()) {
case Status.UNDEPLOYED_VALUE:
this.setOcciComponentState(Status.DEPLOYED);
break;
// TODO: Implement how to deploy this datagatherer.
default:
break;
}
}
// End of user code
// Start of user code Datagatherer_Kind_undeploy_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: undeploy
* - title:
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: undeploy
* - title:
*/
@Override
public void undeploy()
{
public void undeploy() {
LOGGER.debug("Action undeploy() called on " + this);
switch (this.getOcciComponentState().getValue()) {
case Status.ACTIVE_VALUE:
this.setOcciComponentState(Status.UNDEPLOYED);
break;
// TODO: Implement how to undeploy this datagatherer.
case Status.INACTIVE_VALUE:
this.setOcciComponentState(Status.UNDEPLOYED);
break;
case Status.DEPLOYED_VALUE:
this.setOcciComponentState(Status.UNDEPLOYED);
break;
case Status.ERROR_VALUE:
this.setOcciComponentState(Status.UNDEPLOYED);
break;
default:
break;
}
}
// End of user code
// Start of user code Datagatherer_Kind_Stop_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: stop
* - title: Stop the application.
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: stop -
* title: Stop the application.
*/
@Override
public void stop()
{
public void stop() {
LOGGER.debug("Action stop() called on " + this);
// TODO: Implement how to stop this datagatherer.
setOcciComponentState(Status.INACTIVE);
}
// End of user code
// Start of user code Datagatherer_Kind_Start_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: start
* - title: Start the application.
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: start -
* title: Start the application.
*/
@Override
public void start()
{
public void start() {
LOGGER.debug("Action start() called on " + this);
switch (this.getOcciComponentState().getValue()) {
case Status.INACTIVE_VALUE:
this.setOcciComponentState(Status.ACTIVE);
break;
case Status.UNDEPLOYED_VALUE:
this.setOcciComponentState(Status.ACTIVE);
break;
// TODO: Implement how to start this datagatherer.
default:
break;
}
}
// End of user code
}
}
/**
* Copyright (c) 2016-2017 Inria
*
*
* 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:
* - Philippe Merle <philippe.merle@inria.fr>
* - Faiez Zalila <faiez.zalila@inria.fr>
*
* Generated at Wed Dec 19 10:30:40 CET 2018 from platform:/resource/monitoring/model/monitoring.occie by org.eclipse.cmf.occi.core.gen.connector
*/
package de.ugoe.cs.rwm.mocci.connector;
import org.eclipse.cmf.occi.core.AttributeState;
import org.modmacao.occi.platform.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Connector implementation for the OCCI kind:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring#
* - term: processor
* - title: Processor Resource
* Connector implementation for the OCCI kind: - scheme:
* http://schemas.ugoe.cs.rwm/monitoring# - term: processor - title: Processor
* Resource
*/
public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl
{
public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl {
/**
* Initialize the logger.
*/
......@@ -37,8 +34,7 @@ public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl
/**
* Constructs a processor connector.
*/
DataprocessorConnector()
{
DataprocessorConnector() {
LOGGER.debug("Constructor called on " + this);
// TODO: Implement this constructor.
}
......@@ -46,14 +42,13 @@ public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl
//
// OCCI CRUD callback operations.
//
// Start of user code ProcessorocciCreate
/**
* Called when this Processor instance is completely created.
*/
@Override
public void occiCreate()
{
public void occiCreate() {
LOGGER.debug("occiCreate() called on " + this);
// TODO: Implement this callback or remove this method.
}
......@@ -64,8 +59,7 @@ public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl
* Called when this Processor instance must be retrieved.
*/
@Override
public void occiRetrieve()
{
public void occiRetrieve() {
LOGGER.debug("occiRetrieve() called on " + this);
// TODO: Implement this callback or remove this method.
}
......@@ -76,8 +70,7 @@ public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl
* Called when this Processor instance is completely updated.
*/
@Override
public void occiUpdate()
{
public void occiUpdate() {
LOGGER.debug("occiUpdate() called on " + this);
// TODO: Implement this callback or remove this method.
}
......@@ -88,8 +81,7 @@ public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl
* Called when this Processor instance will be deleted.
*/
@Override
public void occiDelete()
{
public void occiDelete() {
LOGGER.debug("occiDelete() called on " + this);
// TODO: Implement this callback or remove this method.
}
......@@ -101,84 +93,116 @@ public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl
// Start of user code Processor_Kind_configure_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: configure
* - title:
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: configure
* - title:
*/
@Override
public void configure()
{
public void configure() {
LOGGER.debug("Action configure() called on " + this);
switch (this.getOcciComponentState().getValue()) {
// TODO: Implement how to configure this processor.
case Status.DEPLOYED_VALUE:
this.setOcciComponentState(Status.INACTIVE);
break;
default:
break;
}
}
// End of user code
// Start of user code Processor_Kind_deploy_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: deploy
* - title:
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: deploy -
* title:
*/
@Override
public void deploy()
{
public void deploy() {
LOGGER.debug("Action deploy() called on " + this);
switch (this.getOcciComponentState().getValue()) {
case Status.UNDEPLOYED_VALUE:
this.setOcciComponentState(Status.DEPLOYED);
break;
// TODO: Implement how to deploy this processor.
default:
break;
}
}
// End of user code
// Start of user code Processor_Kind_undeploy_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: undeploy
* - title:
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: undeploy
* - title:
*/
@Override
public void undeploy()
{
public void undeploy() {
LOGGER.debug("Action undeploy() called on " + this);
switch (this.getOcciComponentState().getValue()) {
case Status.ACTIVE_VALUE:
this.setOcciComponentState(Status.UNDEPLOYED);
break;
case Status.INACTIVE_VALUE:
this.setOcciComponentState(Status.UNDEPLOYED);
break;
// TODO: Implement how to undeploy this processor.
case Status.DEPLOYED_VALUE:
this.setOcciComponentState(Status.UNDEPLOYED);
break;
case Status.ERROR_VALUE:
this.setOcciComponentState(Status.UNDEPLOYED);
break;
default:
break;
}
}
// End of user code
// Start of user code Processor_Kind_Stop_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: stop
* - title: Stop the application.
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: stop -
* title: Stop the application.
*/
@Override
public void stop()
{
public void stop() {
LOGGER.debug("Action stop() called on " + this);
// TODO: Implement how to stop this processor.
setOcciComponentState(Status.INACTIVE);
}
// End of user code
// Start of user code Processor_Kind_Start_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: start
* - title: Start the application.
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: start -
* title: Start the application.
*/
@Override
public void start()
{
LOGGER.debug("Action start() called on " + this);
public void start() {
LOGGER.debug("Action start() called on " + this);
switch (this.getOcciComponentState().getValue()) {
System.out.println(this.attributes);
LOGGER.debug("Action start() called on " + this);
//this.attributes.remove(sensorlocation);
System.out.println(this.attributes);
case Status.INACTIVE_VALUE:
this.setOcciComponentState(Status.ACTIVE);
break;
case Status.UNDEPLOYED_VALUE:
this.setOcciComponentState(Status.ACTIVE);
break;
default:
break;
}
}
// End of user code
}
}
/**
* Copyright (c) 2016-2017 Inria
*
*
* 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:
* - Philippe Merle <philippe.merle@inria.fr>
* - Faiez Zalila <faiez.zalila@inria.fr>
*
* Generated at Thu Jan 03 13:17:39 CET 2019 from platform:/resource/monitoring/model/monitoring.occie by org.eclipse.cmf.occi.core.gen.connector
*/
package de.ugoe.cs.rwm.mocci.connector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Connector implementation for the OCCI kind:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring#
* - term: monitoringproperty
* - title: MonitoringProperty Component
* Connector implementation for the OCCI kind: - scheme:
* http://schemas.ugoe.cs.rwm/monitoring# - term: monitoringproperty - title:
* MonitoringProperty Component
*/
public class MonitorablepropertyConnector extends monitoring.impl.MonitorablepropertyImpl
{
public class MonitorablepropertyConnector extends monitoring.impl.MonitorablepropertyImpl {
/**
* Initialize the logger.
*/
......@@ -36,8 +33,7 @@ public class MonitorablepropertyConnector extends monitoring.impl.Monitorablepro
/**
* Constructs a monitoringproperty connector.
*/
MonitorablepropertyConnector()
{
MonitorablepropertyConnector() {
LOGGER.debug("Constructor called on " + this);
// TODO: Implement this constructor.
}
......@@ -45,14 +41,13 @@ public class MonitorablepropertyConnector extends monitoring.impl.Monitorablepro
//
// OCCI CRUD callback operations.
//
// Start of user code MonitoringpropertyocciCreate
/**
* Called when this Monitoringproperty instance is completely created.
*/
@Override
public void occiCreate()
{
public void occiCreate() {
LOGGER.debug("occiCreate() called on " + this);
// TODO: Implement this callback or remove this method.
}
......@@ -63,8 +58,7 @@ public class MonitorablepropertyConnector extends monitoring.impl.Monitorablepro
* Called when this Monitoringproperty instance must be retrieved.
*/
@Override
public void occiRetrieve()
{
public void occiRetrieve() {
LOGGER.debug("occiRetrieve() called on " + this);
// TODO: Implement this callback or remove this method.
}
......@@ -75,8 +69,7 @@ public class MonitorablepropertyConnector extends monitoring.impl.Monitorablepro
* Called when this Monitoringproperty instance is completely updated.
*/
@Override
public void occiUpdate()
{
public void occiUpdate() {
LOGGER.debug("occiUpdate() called on " + this);
// TODO: Implement this callback or remove this method.
}
......@@ -87,8 +80,7 @@ public class MonitorablepropertyConnector extends monitoring.impl.Monitorablepro
* Called when this Monitoringproperty instance will be deleted.
*/
@Override
public void occiDelete()
{
public void occiDelete() {
LOGGER.debug("occiDelete() called on " + this);
// TODO: Implement this callback or remove this method.
}
......@@ -98,7 +90,4 @@ public class MonitorablepropertyConnector extends monitoring.impl.Monitorablepro
// Monitoringproperty actions.
//
}
}
/**
* Copyright (c) 2016-2017 Inria
*
*
* 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:
* - Philippe Merle <philippe.merle@inria.fr>
* - Faiez Zalila <faiez.zalila@inria.fr>
*
* Generated at Thu Jan 03 13:17:39 CET 2019 from platform:/resource/monitoring/model/monitoring.occie by org.eclipse.cmf.occi.core.gen.connector
*/
package de.ugoe.cs.rwm.mocci.connector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Connector implementation for the OCCI kind:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring#
* - term: martpublisher
* - title: MartPublisher Mixin
* Connector implementation for the OCCI kind: - scheme:
* http://schemas.ugoe.cs.rwm/monitoring# - term: martpublisher - title:
* MartPublisher Mixin
*/
public class OcciresultproviderConnector extends monitoring.impl.OcciresultproviderImpl
{
public class OcciresultproviderConnector extends monitoring.impl.OcciresultproviderImpl {
/**
* Initialize the logger.
*/
......@@ -36,15 +33,10 @@ public class OcciresultproviderConnector extends monitoring.impl.Occiresultprovi
/**
* Constructs a martpublisher connector.
*/
OcciresultproviderConnector()
{
OcciresultproviderConnector() {
LOGGER.debug("Constructor called on " + this);
// TODO: Implement this constructor.
}
// End of user code
}
}
/**
* Copyright (c) 2016-2017 Inria
*
*
* 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:
* - Philippe Merle <philippe.merle@inria.fr>
* - Faiez Zalila <faiez.zalila@inria.fr>
*
* Generated at Wed Dec 19 10:30:40 CET 2018 from platform:/resource/monitoring/model/monitoring.occie by org.eclipse.cmf.occi.core.gen.connector
*/
package de.ugoe.cs.rwm.mocci.connector;
import java.util.LinkedList;
import java.util.List;
import java.util.NoSuchElementException;
import org.eclipse.cmf.occi.core.AttributeState;
import org.eclipse.cmf.occi.core.Link;
import org.eclipse.cmf.occi.core.MixinBase;
import org.eclipse.cmf.occi.core.Resource;
import org.eclipse.cmf.occi.core.impl.OCCIFactoryImpl;
import org.modmacao.occi.platform.Component;
import org.modmacao.occi.platform.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import monitoring.Monitorableproperty;
import monitoring.Occiresultprovider;
import monitoring.Sensor;
/**
* Connector implementation for the OCCI kind:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring#
* - term: publisher
* - title: Publisher Resource
* Connector implementation for the OCCI kind: - scheme:
* http://schemas.ugoe.cs.rwm/monitoring# - term: publisher - title: Publisher
* Resource
*/
public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl
{
public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl {
/**
* Initialize the logger.
*/
private static Logger LOGGER = LoggerFactory.getLogger(ResultproviderConnector.class);
private Thread simulation;
//private Occiresultprovider occiResProv;
// private Occiresultprovider occiResProv;
// Start of user code Publisherconnector_constructor
/**
* Constructs a publisher connector.
*/
ResultproviderConnector()
{
ResultproviderConnector() {
LOGGER.debug("Constructor called on " + this);
}
// End of user code
//
// OCCI CRUD callback operations.
//
// Start of user code PublisherocciCreate
/**
* Called when this Publisher instance is completely created.
*/
@Override
public void occiCreate()
{
public void occiCreate() {
LOGGER.debug("occiCreate() called on " + this);
// TODO: Implement this callback or remove this method.
......@@ -86,12 +68,11 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl
* Called when this Publisher instance must be retrieved.
*/
@Override
public void occiRetrieve()
{
public void occiRetrieve() {
LOGGER.debug("occiRetrieve() called on " + this);
if(this.getOcciComponentState().getValue() == Status.ACTIVE.getValue()) {
if(simulation == null) {
if (this.getOcciComponentState().getValue() == Status.ACTIVE.getValue()) {
if (simulation == null) {
ResultproviderSimulation sim = new ResultproviderSimulation(getMonProp(getSensor()));
simulation = new Thread(sim);
simulation.start();
......@@ -106,8 +87,7 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl
* Called when this Publisher instance is completely updated.
*/
@Override
public void occiUpdate()
{
public void occiUpdate() {
LOGGER.debug("occiUpdate() called on " + this);
// TODO: Implement this callback or remove this method.
}
......@@ -117,11 +97,11 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl
/**
* Called when this Publisher instance will be deleted.
*/
@SuppressWarnings("deprecation")
@Override
public void occiDelete()
{
public void occiDelete() {
LOGGER.debug("occiDelete() called on " + this);
if(simulation!= null) {
if (simulation != null) {
simulation.stop();
}
// TODO: Implement this callback or remove this method.
......@@ -134,167 +114,155 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl
// Start of user code Publisher_Kind_configure_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: configure
* - title:
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: configure
* - title:
*/
@Override
public void configure()
{
public void configure() {
LOGGER.debug("Action configure() called on " + this);
switch(this.getOcciComponentState().getValue()) {
switch (this.getOcciComponentState().getValue()) {
case Status.DEPLOYED_VALUE:
this.setOcciComponentState(Status.INACTIVE);
this.setOcciComponentState(Status.INACTIVE);
break;
default:
break;
}
// TODO: Implement how to configure this publisher.
}
// End of user code
// Start of user code Publisher_Kind_deploy_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: deploy
* - title:
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: deploy -
* title:
*/
@Override
public void deploy()
{
public void deploy() {
LOGGER.debug("Action deploy() called on " + this);
switch(this.getOcciComponentState().getValue()) {
switch (this.getOcciComponentState().getValue()) {
case Status.UNDEPLOYED_VALUE:
this.setOcciComponentState(Status.DEPLOYED);
break;
default:
break;
}
}
}
// End of user code
// Start of user code Publisher_Kind_undeploy_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: undeploy
* - title:
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: undeploy
* - title:
*/
@SuppressWarnings("deprecation")
@Override
public void undeploy()
{
public void undeploy() {
LOGGER.debug("Action undeploy() called on " + this);
switch(this.getOcciComponentState().getValue()) {
switch (this.getOcciComponentState().getValue()) {
case Status.ACTIVE_VALUE:
this.setOcciComponentState(Status.UNDEPLOYED);
if(simulation!= null) {
if (simulation != null) {
simulation.stop();
}
break;
case Status.INACTIVE_VALUE:
this.setOcciComponentState(Status.UNDEPLOYED);
break;
case Status.DEPLOYED_VALUE:
this.setOcciComponentState(Status.UNDEPLOYED);
break;
case Status.ERROR_VALUE:
this.setOcciComponentState(Status.UNDEPLOYED);
break;
default:
break;
}
}
}
// End of user code
// Start of user code Publisher_Kind_Stop_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: stop
* - title: Stop the application.
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: stop -
* title: Stop the application.
*/
@SuppressWarnings("deprecation")
@Override
public void stop()
{
public void stop() {
LOGGER.debug("Action stop() called on " + this);
if(simulation!= null) {
if (simulation != null) {
simulation.stop();
}
setOcciComponentState(Status.INACTIVE);
}
// End of user code
// Start of user code Publisher_Kind_Start_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: start
* - title: Start the application.
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: start -
* title: Start the application.
*/
@Override
public void start()
{
public void start() {
LOGGER.debug("Action start() called on " + this);
switch(this.getOcciComponentState().getValue()) {
switch (this.getOcciComponentState().getValue()) {
case Status.INACTIVE_VALUE:
this.setOcciComponentState(Status.ACTIVE);
if(simulation == null) {
ResultproviderSimulation sim = new ResultproviderSimulation(getMonProp(getSensor()));
simulation = new Thread(sim);
simulation.start();
}
this.setOcciComponentState(Status.ACTIVE);
if (simulation == null || simulation.isAlive() == false) {
ResultproviderSimulation sim = new ResultproviderSimulation(getMonProp(getSensor()));
simulation = new Thread(sim);
simulation.start();
}
break;
case Status.UNDEPLOYED_VALUE:
this.setOcciComponentState(Status.ACTIVE);
if(simulation == null) {
ResultproviderSimulation sim = new ResultproviderSimulation(getMonProp(getSensor()));
simulation = new Thread(sim);
simulation.start();
}
break;
this.setOcciComponentState(Status.ACTIVE);
if (simulation == null) {
ResultproviderSimulation sim = new ResultproviderSimulation(getMonProp(getSensor()));
simulation = new Thread(sim);
simulation.start();
}
break;
default:
break;
}
}
}
// End of user code
private Sensor getSensor() {
for(Link link: this.getRlinks()) {
if(link.getSource() instanceof Sensor) {
for (Link link : this.getRlinks()) {
if (link.getSource() instanceof Sensor) {
return ((Sensor) link.getSource());
}
}
throw new NoSuchElementException("No containing sensor found!");
}
private Monitorableproperty getMonProp(Sensor sensor) {
for(Link link: sensor.getLinks()) {
if(link instanceof Monitorableproperty) {
for (Link link : sensor.getLinks()) {
if (link instanceof Monitorableproperty) {
return ((Monitorableproperty) link);
}
}
throw new NoSuchElementException("No monitorableproperty found in sensor!");
}
}
}
/**
* Copyright (c) 2018-2019 University of Goettingen
* 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:
* - Johannes Erbel <johannes.erbel@cs.uni-goettingen.de>
*/
package de.ugoe.cs.rwm.mocci.connector;
import java.io.IOException;
......@@ -7,43 +18,44 @@ import java.util.Properties;
public final class ResultproviderHelper {
Properties props;
private final static String FILENAME = "resultprovider.properties";
public ResultproviderHelper() {
loadProperties();
}
/**
* Getter method for providing the properties of this ResultProviderHelper.
* Properties will be read from local file resultprovider.properties.
*
* @return The properties
*/
public Properties getProperties() {
if (props == null)
if (props == null) {
loadProperties();
}
return props;
}
}
private void loadProperties() {
props = new Properties();
InputStream input = null;
try {
input = this.getClass().getClassLoader().getResourceAsStream(FILENAME);
props.load(input);
} catch (IOException ex) {
ex.printStackTrace();
} finally{
if(input!=null){
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
InputStream input = null;
try {
input = this.getClass().getClassLoader().getResourceAsStream(FILENAME);
props.load(input);
} catch (IOException ex) {
ex.printStackTrace();
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
}
}
}
/**
* Copyright (c) 2018-2019 University of Goettingen
* 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:
* - Johannes Erbel <johannes.erbel@cs.uni-goettingen.de>
*/
package de.ugoe.cs.rwm.mocci.connector;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.cmf.occi.core.AttributeState;
import org.eclipse.cmf.occi.core.impl.OCCIFactoryImpl;
......@@ -13,52 +25,62 @@ import org.slf4j.LoggerFactory;
import monitoring.Monitorableproperty;
public class ResultproviderSimulation implements Runnable{
public class ResultproviderSimulation implements Runnable {
private static Logger LOGGER = LoggerFactory.getLogger(ResultproviderSimulation.class);
private Monitorableproperty monProp;
private OCCIFactoryImpl factory = new OCCIFactoryImpl();
private static Random random;
private int interval;
private List<String> results;
public ResultproviderSimulation(Monitorableproperty monProp) {
this.monProp = monProp;
String property = getProperty(monProp.getMonitoringProperty());
LOGGER.info("Monitoring property for" + monProp.getMonitoringProperty() + ": " + property);
List<String> items = new ArrayList<String>(Arrays.asList(property.split("\\s*,\\s*")));
this.interval = Integer.parseInt(items.get(items.size()-1));
String lastItem = items.get(items.size()-1);
items.remove(items.get(items.size()-1));
this.interval = Integer.parseInt(items.get(items.size() - 1));
items.remove(items.get(items.size() - 1));
String itemsString = String.join(",", items);
Pattern p = Pattern.compile("\'([^\']*)\'");
Matcher m = p.matcher(itemsString);
if (m.find() == true) {
items.clear();
while (m.find()) {
items.add(m.group(1));
}
}
this.results = items;
LOGGER.info("Creating Simulation for: " + monProp.getMonitoringProperty() + "; with values: " + results + "; and interval: " + interval);
LOGGER.info("Creating Simulation for: " + monProp.getMonitoringProperty() + "; with values: " + results
+ "; and interval: " + interval);
}
@Override
public void run() {
while(true) {
while (true) {
try {
Thread.sleep(interval);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
AttributeState monPropAttr = factory.createAttributeState();
monPropAttr.setName("monitoring.result");
int randomElementIndex = ThreadLocalRandom.current().nextInt(results.size());
String value = results.get(randomElementIndex);
monPropAttr.setValue(value);
monProp.setMonitoringResult(value);
LOGGER.info("MonProp: " + monProp.getMonitoringProperty() + ", set to: " + value + "(" +monProp.getId()+")" );
LOGGER.info(
"MonProp: " + monProp.getMonitoringProperty() + ", set to: " + value + "(" + monProp.getId() + ")");
monProp.getAttributes().add(monPropAttr);
}
}
private String getProperty(String monitoringProperty) {
return new ResultproviderHelper().getProperties().getProperty(monitoringProperty);
}
}
/**
* Copyright (c) 2016-2017 Inria
*
*
* 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:
* - Philippe Merle <philippe.merle@inria.fr>
* - Faiez Zalila <faiez.zalila@inria.fr>
*
* Generated at Wed Dec 05 12:12:23 CET 2018 from platform:/resource/monitoring/model/monitoring.occie by org.eclipse.cmf.occi.core.gen.connector
*/
package de.ugoe.cs.rwm.mocci.connector;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.cmf.occi.core.Link;
import org.modmacao.cm.ConfigurationManagementTool;
import org.modmacao.cm.ansible.AnsibleCMTool;
import org.modmacao.core.connector.ApplicationConnector;
import org.modmacao.occi.platform.Component;
import org.modmacao.occi.platform.Componentlink;
import org.modmacao.occi.platform.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Connector implementation for the OCCI kind:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring#
* - term: sensor
* - title: Sensor Component
* Connector implementation for the OCCI kind: - scheme:
* http://schemas.ugoe.cs.rwm/monitoring# - term: sensor - title: Sensor
* Component
*/
public class SensorConnector extends monitoring.impl.SensorImpl
{
public class SensorConnector extends monitoring.impl.SensorImpl {
/**
* Initialize the logger.
*/
......@@ -48,8 +41,7 @@ public class SensorConnector extends monitoring.impl.SensorImpl
/**
* Constructs a sensor connector.
*/
SensorConnector()
{
SensorConnector() {
LOGGER.debug("Constructor called on " + this);
// TODO: Implement this constructor.
}
......@@ -57,14 +49,13 @@ public class SensorConnector extends monitoring.impl.SensorImpl
//
// OCCI CRUD callback operations.
//
// Start of user code SensorocciCreate
/**
* Called when this Sensor instance is completely created.
*/
@Override
public void occiCreate()
{
public void occiCreate() {
LOGGER.debug("occiCreate() called on " + this);
// TODO: Implement this callback or remove this method.
}
......@@ -75,8 +66,7 @@ public class SensorConnector extends monitoring.impl.SensorImpl
* Called when this Sensor instance must be retrieved.
*/
@Override
public void occiRetrieve()
{
public void occiRetrieve() {
LOGGER.debug("occiRetrieve() called on " + this);
// TODO: Implement this callback or remove this method.
}
......@@ -87,8 +77,7 @@ public class SensorConnector extends monitoring.impl.SensorImpl
* Called when this Sensor instance is completely updated.
*/
@Override
public void occiUpdate()
{
public void occiUpdate() {
LOGGER.debug("occiUpdate() called on " + this);
// TODO: Implement this callback or remove this method.
}
......@@ -99,8 +88,7 @@ public class SensorConnector extends monitoring.impl.SensorImpl
* Called when this Sensor instance will be deleted.
*/
@Override
public void occiDelete()
{
public void occiDelete() {
LOGGER.debug("occiDelete() called on " + this);
// TODO: Implement this callback or remove this method.
}
......@@ -112,224 +100,206 @@ public class SensorConnector extends monitoring.impl.SensorImpl
// Start of user code Sensor_Kind_deploy_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: deploy
* - title:
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: deploy -
* title:
*/
@Override
public void deploy()
{
public void deploy() {
LOGGER.debug("Action deploy() called on " + this);
// Application State Machine.
switch(getOcciAppState().getValue()) {
switch (getOcciAppState().getValue()) {
case Status.UNDEPLOYED_VALUE:
LOGGER.debug("Fire transition(state=undeployed, action=\"deploy\")...");
for (Component component: this.getConnectedComponents()) {
for (Component component : this.getConnectedComponents()) {
component.deploy();
}
setOcciAppState(Status.DEPLOYED);
}
setOcciAppState(Status.DEPLOYED);
break;
default:
break;
}
}
// End of user code
// Start of user code Sensor_Kind_undeploy_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: undeploy
* - title:
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: undeploy
* - title:
*/
@Override
public void undeploy()
{
public void undeploy() {
LOGGER.debug("Action undeploy() called on " + this);
// Application State Machine.
switch(getOcciAppState().getValue()) {
switch (getOcciAppState().getValue()) {
case Status.ACTIVE_VALUE:
LOGGER.debug("Fire transition(state=active, action=\"undeploy\")...");
for (Component component: this.getConnectedComponents()) {
for (Component component : this.getConnectedComponents()) {
component.stop();
}
this.stop();
for (Component component: this.getConnectedComponents()) {
for (Component component : this.getConnectedComponents()) {
component.undeploy();
}
setOcciAppState(Status.UNDEPLOYED);
setOcciAppState(Status.UNDEPLOYED);
break;
case Status.INACTIVE_VALUE:
LOGGER.debug("Fire transition(state=inactive, action=\"undeploy\")...");
for (Component component: this.getConnectedComponents()) {
for (Component component : this.getConnectedComponents()) {
component.undeploy();
}
setOcciAppState(Status.UNDEPLOYED);
setOcciAppState(Status.UNDEPLOYED);
break;
case Status.DEPLOYED_VALUE:
LOGGER.debug("Fire transition(state=deployed, action=\"undeploy\")...");
for (Component component: this.getConnectedComponents()) {
for (Component component : this.getConnectedComponents()) {
component.undeploy();
}
setOcciAppState(Status.UNDEPLOYED);
setOcciAppState(Status.UNDEPLOYED);
break;
case Status.ERROR_VALUE:
LOGGER.debug("Fire transition(state=error, action=\"undeploy\")...");
for (Component component: this.getConnectedComponents()) {
for (Component component : this.getConnectedComponents()) {
component.undeploy();
}
setOcciAppState(Status.UNDEPLOYED);
setOcciAppState(Status.UNDEPLOYED);
break;
default:
break;
}
}
}
// End of user code
// Start of user code Sensor_Kind_Stop_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: stop
* - title: Stop the application.
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: stop -
* title: Stop the application.
*/
@Override
public void stop()
{
public void stop() {
LOGGER.debug("Action stop() called on " + this);
// Application State Machine.
switch(getOcciAppState().getValue()) {
switch (getOcciAppState().getValue()) {
case Status.ACTIVE_VALUE:
LOGGER.debug("Fire transition(state=active, action=\"stop\")...");
for (Component component: this.getConnectedComponents()) {
for (Component component : this.getConnectedComponents()) {
component.stop();
}
setOcciAppState(Status.INACTIVE);
setOcciAppState(Status.INACTIVE);
break;
default:
break;
}
}
// TODO: Implement how to stop this sensor.
}
// End of user code
// Start of user code Sensor_Kind_configure_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: configure
* - title:
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: configure
* - title:
*/
@Override
public void configure()
{
int status = -1;
public void configure() {
LOGGER.debug("Action configure() called on " + this);
// Application State Machine.
switch(getOcciAppState().getValue()) {
switch (getOcciAppState().getValue()) {
case Status.DEPLOYED_VALUE:
LOGGER.debug("Fire transition(state=deployed, action=\"configure\")...");
for (Component component: this.getConnectedComponents()) {
for (Component component : this.getConnectedComponents()) {
component.configure();
}
setOcciAppState(Status.INACTIVE);
setOcciAppState(Status.INACTIVE);
break;
default:
break;
}
}
}
// End of user code
// Start of user code Sensor_Kind_Start_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: start
* - title: Start the application.
* Implement OCCI action: - scheme:
* http://schemas.modmacao.org/occi/platform/component/action# - term: start -
* title: Start the application.
*/
@Override
public void start()
{
int status = -1;
public void start() {
LOGGER.debug("Action start() called on " + this);
// Application State Machine.
switch(getOcciAppState().getValue()) {
switch (getOcciAppState().getValue()) {
case Status.INACTIVE_VALUE:
LOGGER.debug("Fire transition(state=inactive, action=\"start\")...");
for (Component component: this.getConnectedComponents()) {
for (Component component : this.getConnectedComponents()) {
component.start();
}
setOcciAppState(Status.ACTIVE);
break;
setOcciAppState(Status.ACTIVE);
break;
case Status.UNDEPLOYED_VALUE:
LOGGER.debug("Fire transition(state=undeployed, action=\"start\")...");
// First deploy components
for (Component component: this.getConnectedComponents()) {
for (Component component : this.getConnectedComponents()) {
component.deploy();
}
this.deploy();
// then configure them
for (Component component: this.getConnectedComponents()) {
for (Component component : this.getConnectedComponents()) {
component.configure();
}
this.configure();
// then start them
for (Component component: this.getConnectedComponents()) {
for (Component component : this.getConnectedComponents()) {
component.start();
}
setOcciAppState(Status.ACTIVE);
setOcciAppState(Status.ACTIVE);
break;
default:
break;
}
}
}
// End of user code
private List<Component> getConnectedComponents() {
LinkedList<Component> connectedComponents = new LinkedList<Component>();
for (Link link: this.getLinks()) {
for (Link link : this.getLinks()) {
if (link instanceof Componentlink) {
connectedComponents.add((Component) link.getTarget());
}
}
return connectedComponents;
}
private boolean assertCompsStatusEquals(List<Component> components, Status status) {
for (Component component: components) {
if (component.getOcciComponentState().getValue() != status.getValue()) {
LOGGER.debug("Missmatching state of component " + component.getTitle() + " detected. "
+ "Expected " + status.getName() + " but was "
+ component.getOcciComponentState().getName() + ".");
return false;
}
}
return true;
}
}
}
}
/*******************************************************************************
* Copyright (c) 2019 University of Goettingen.
* 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:
* - Johannes Erbel <johannes.erbel@cs.uni-goettingen.de>
*******************************************************************************/
/**
*
*/
/**
* Main package for mocci connector dummy.
*
* @author erbel
*
*/
package de.ugoe.cs.rwm.mocci.connector;
\ No newline at end of file
package de.ugoe.cs.rwm.mocci.connector.dummy;
import static org.junit.Assert.assertTrue;
import java.util.NoSuchElementException;
import org.eclipse.cmf.occi.core.Link;
import org.eclipse.cmf.occi.infrastructure.Compute;
import org.eclipse.cmf.occi.infrastructure.InfrastructureFactory;
import org.junit.BeforeClass;
import org.junit.Test;
import org.modmacao.occi.platform.Componentlink;
import org.modmacao.occi.platform.PlatformFactory;
import org.modmacao.occi.platform.Status;
import de.ugoe.cs.rwm.mocci.connector.ConnectorFactory;
import monitoring.Datagatherer;
import monitoring.Monitorableproperty;
import monitoring.Sensor;
public class DatagathererTest {
ConnectorFactory fac = new ConnectorFactory();
PlatformFactory pFac = PlatformFactory.eINSTANCE;
@BeforeClass
public static void OCCIRegistrySetup() {
TestUtility.extensionRegistrySetup();
}
@Test
public void occiCreateDatagatherer() {
Datagatherer dg = fac.createDatagatherer();
dg.occiCreate();
assertTrue(true);
}
@Test
public void getDatagathererInactive() {
Datagatherer dg = createDatagatherer(Status.UNDEPLOYED);
Monitorableproperty monProp = getMonProp(getSensor(dg));
assertTrue(monProp.getMonitoringResult() == null);
dg.occiRetrieve();
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
assertTrue(monProp.getMonitoringResult() == null);
}
@Test
public void DatagathererLifecycleToStart() {
Datagatherer dg = createDatagatherer(Status.UNDEPLOYED);
dg.deploy();
assertTrue(inState(dg, Status.DEPLOYED));
dg.configure();
assertTrue(inState(dg, Status.INACTIVE));
dg.start();
assertTrue(inState(dg, Status.ACTIVE));
}
@Test
public void DatagathererLifecycleToUndeployed() {
Datagatherer dg = createDatagatherer(Status.ACTIVE);
dg.stop();
assertTrue(inState(dg, Status.INACTIVE));
dg.undeploy();
assertTrue(inState(dg, Status.UNDEPLOYED));
Datagatherer rp2 = createDatagatherer(Status.DEPLOYED);
rp2.undeploy();
assertTrue(inState(dg, Status.UNDEPLOYED));
}
@Test
public void DatagathererLifecycleDeployToUndeployed() {
Datagatherer dg = createDatagatherer(Status.DEPLOYED);
dg.undeploy();
assertTrue(inState(dg, Status.UNDEPLOYED));
}
@Test
public void DatagathererLifecycleActiveToUndeploy() {
Datagatherer dg = createDatagatherer(Status.UNDEPLOYED);
dg.start();
dg.undeploy();
assertTrue(inState(dg, Status.UNDEPLOYED));
}
@Test
public void DatagathererLifecycleActiveToStop() {
Datagatherer dg = createDatagatherer(Status.UNDEPLOYED);
dg.start();
dg.stop();
assertTrue(inState(dg, Status.INACTIVE));
dg.start();
assertTrue(inState(dg, Status.ACTIVE));
}
@Test
public void occiDatagathererRequests() {
Datagatherer dg = createDatagatherer(Status.UNDEPLOYED);
dg.occiCreate();
dg.occiRetrieve();
dg.occiUpdate();
dg.occiDelete();
assertTrue(true);
}
private Boolean inState(Datagatherer dg, Status deployed) {
return dg.getOcciComponentState().getValue() == deployed.getValue();
}
private Sensor getSensor(Datagatherer dg) {
for (Link link : dg.getRlinks()) {
if (link.getSource() instanceof Sensor) {
return ((Sensor) link.getSource());
}
}
throw new NoSuchElementException("No containing sensor found!");
}
private Monitorableproperty getMonProp(Sensor sensor) {
for (Link link : sensor.getLinks()) {
if (link instanceof Monitorableproperty) {
return ((Monitorableproperty) link);
}
}
throw new NoSuchElementException("No monitorableproperty found in sensor!");
}
private Datagatherer createDatagatherer(Status state) {
Sensor sens = fac.createSensor();
Datagatherer dg = fac.createDatagatherer();
dg.setOcciComponentState(state);
Componentlink cLink = pFac.createComponentlink();
cLink.setSource(sens);
cLink.setTarget(dg);
Compute vm = InfrastructureFactory.eINSTANCE.createCompute();
Monitorableproperty monProp = fac.createMonitorableproperty();
monProp.setSource(sens);
monProp.setTarget(vm);
monProp.setMonitoringProperty("CPU");
return dg;
}
}