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
Showing
with 1184 additions and 1213 deletions
/**
* 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 Jan 02 16:14:48 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 Wed Jan 02 16:14:48 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) 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.
*
* @author erbel
*
*/
package de.ugoe.cs.rwm.mocci.connector;
\ No newline at end of file
/**
* 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.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public final class PropertiesHelper {
Properties props;
private final static String FILENAME = "mocci.properties";
public PropertiesHelper() {
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) {
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();
}
}
}
}
}
package de.ugoe.cs.rwm.mocci.connector.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.NoSuchElementException;
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.Link;
import org.eclipse.cmf.occi.core.MixinBase;
import org.eclipse.cmf.occi.core.impl.OCCIFactoryImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.ugoe.cs.rwm.mocci.connector.SensorConnector;
import monitoring.Monitorableproperty;
import monitoring.Sensor;
public class SensorSimulation implements Runnable {
private static Logger LOGGER = LoggerFactory.getLogger(SensorSimulation.class);
private Monitorableproperty monProp;
private OCCIFactoryImpl factory = new OCCIFactoryImpl();
private int interval;
private List<String> results;
private MixinBase simMixing;
public SensorSimulation(SensorConnector sensor) {
this.simMixing = sensor.getSimulationMixin();
this.monProp = getMonProp(sensor);
String property = getAttribute(simMixing, "sim.monitoring.results");
LOGGER.info("Monitoring property for" + monProp.getMonitoringProperty() + ": " + property);
List<String> items = new ArrayList<String>(Arrays.asList(property.split("\\s*,\\s*")));
this.interval = Integer.parseInt(getAttribute(simMixing, "sim.change.rate"));
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(0));
}
}
this.results = items;
LOGGER.info("Creating Simulation for: " + monProp.getMonitoringProperty() + "; with values: " + results
+ "; and interval: " + interval);
}
@Override
public void run() {
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() + ")");
monProp.getAttributes().add(monPropAttr);
}
}
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!");
}
public static String getAttribute(MixinBase simMixing, String s) {
for (AttributeState attr : simMixing.getAttributes()) {
if (attr.getName().equals(s)) {
return attr.getValue();
}
}
return "";
}
}
......@@ -3,6 +3,5 @@
<classpathentry kind="src" path="src-gen"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
// 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 "http://www.jabylon.org/maven/"
}
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: 'org.eclipse.cmf.occi', name: 'core', version: '1.0.0'
......@@ -36,45 +6,45 @@ dependencies {
//occiware
compile group: 'org.modmacao.occi', name: 'platform', version: '1.0.0'
compile group: 'org.modmacao.occi.platform', name: 'edit', version: '1.0.0'
//maven
compile group: 'org.eclipse.emf', name: 'edit', version: '2.9.0'
compile "org.eclipse.core:org.eclipse.core.runtime:3.7.0"
testCompile group: 'junit', name: 'junit', version: '4.12'
}
sourceSets {
main {
java {
srcDir 'src-gen'
}
//output.classesDir = "$workDir/client/program"
}
//output.classesDir = "$workDir/client/program"
}
}
processResources {
from("."){
include("model/")
include("plugin.xml")
include("plugin.properties")
}
from(".") {
include("model/")
include("plugin.xml")
include("plugin.properties")
}
}
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'))
}
pom.version = "1.0.0"
pom.artifactId = "edit"
pom.groupId = "de.ugoe.cs.rwm.mocci.model"
}
if (System.getenv('VERSION') != null) {
pom.version = System.getenv('VERSION')
println "Version is set to: " + System.getenv('VERSION')
}
pom.version = "SNAPSHOT"
pom.artifactId = "edit"
pom.groupId = "de.ugoe.cs.rwm.mocci.model"
}
}
}
\ No newline at end of file
......@@ -3,6 +3,5 @@
<classpathentry kind="src" path="src-gen"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
# Monitoring Extension
This component represents the OCCI monitoring extension, we generated using [OCCI-Studio](https://github.com/occiware/OCCI-Studio).
The elements introduced in this extension mainly inherit from elements of the enhanced platform extension of [MoDMaCAO](https://github.com/occiware/MoDMaCAO),
as shown in the Figure below. As any other extension generated with OCCI-Studio the monitoring extension can be [registered as a plugin](https://gitlab.gwdg.de/rwm/de.ugoe.cs.rwm.mocci/blob/master/doc/studio.md) within Eclipse, OCCI-Studio, and the MartServer.
## The Sensor Element
The Sensor element represents a top level element used to easily manage all monitoring devices it contains.
The containment relationship to its monitoring devices is modeled via ComponentLinks.
As Sensor inherits Application, it gains access to attributes reflecting its current state, as well as actions to manage its lifecycle.
Thus, the monitoring devices can be deployed by accessing the sensor directly, but also by addressing each device separately.
To specify the object a sensor monitors, it can be connected over a MonitorableProperty to the corresponding resource.
The property itself defines two attributes defining the name of the property it monitors, and its results.
## The Monitoring Components
Each monitoring device (DataGatherer, DataProcessor, ResultProvider) inherit from component.
Thus, each monitoring component gains access to actions to deploy, configure, start, stop, and undeploy it.
When not using the dummy connector, the execution of these actions trigger the execution of configuration management scripts linked to the individual monitoring device.
The name of the scripts are assigned over user Mixins attached to the Component, which is located in the roles folder of the MartServer.
To define where each monitoring device is deployed PlacementLinks are used connecting the device to the VM it is deployed on.
Thus, each device can be hosted by different VM.
![Ext](./monExt.jpg "Ext")
\ No newline at end of file
This diff is collapsed.
......@@ -14,11 +14,11 @@
<kinds name="ResultProvider" scheme="http://schemas.ugoe.cs.rwm/monitoring#" title="Publisher Resource">
<parent href="http://schemas.modmacao.org/occi/platform#//@kinds[term='component']"/>
</kinds>
<kinds name="MonitorableProperty" scheme="http://schemas.ugoe.cs.rwm/monitoring#" title="MonitorableProperty Component" target="//@kinds[term='sensor']">
<kinds name="MonitorableProperty" scheme="http://schemas.ugoe.cs.rwm/monitoring#" title="MonitorableProperty Component" source="//@kinds[term='sensor']">
<attributes name="monitoring.property" mutable="false" required="true" description="" type="//@types.0"/>
<attributes name="monitoring.result" mutable="true" description="" type="//@types.0"/>
<parent href="http://schemas.ogf.org/occi/core#//@kinds[term='link']"/>
<source href="http://schemas.ogf.org/occi/core#//@kinds[term='resource']"/>
<target href="http://schemas.ogf.org/occi/core#//@kinds[term='resource']"/>
</kinds>
<mixins name="OCCIResultProvider" scheme="http://schemas.ugoe.cs.rwm/monitoring#" title="OCCIResultProvider Mixin" applies="//@kinds[term='resultprovider']">
<attributes name="result.provider.endpoint" mutable="true" required="true" description="Genereic address to be used by the result provider." type="//@types.0"/>
......
de.ugoe.cs.rwm.mocci.model/monExt.jpg

92.9 KiB

This diff is collapsed.
de.ugoe.cs.rwm.mocci.model/new Extension diagram.jpg

1.1 MiB

This diff is collapsed.