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 1289 additions and 663 deletions
// 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: 'org.modmacao', name: 'core', 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'
}
......@@ -51,27 +21,32 @@ sourceSets {
main {
java {
srcDir 'src-gen'
}
//output.classesDir = "$workDir/client/program"
}
//output.classesDir = "$workDir/client/program"
}
}
processResources {
from("."){
include("plugin.xml")
}
from(".") {
include("plugin.xml")
include("mocci.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 = "connector"
pom.groupId = "de.ugoe.cs.rwm.mocci"
}
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"
}
}
}
de.ugoe.cs.rwm.mocci.connector/example.jpg

349 KiB

default_endpoint=172.19.0.1:8080
\ 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.eclipse.cmf.occi.infrastructure.Compute;
import org.modmacao.cm.ConfigurationManagementTool;
import org.modmacao.cm.ansible.AnsibleCMTool;
import org.modmacao.occi.platform.Component;
import org.modmacao.occi.platform.Status;
import modmacao.Executiondependency;
import modmacao.Installationdependency;
public class ComponentManager {
private ConfigurationManagementTool cmtool = new AnsibleCMTool();
private Component comp;
public ComponentManager(Component comp) {
this.comp = comp;
}
public void undeploy() {
switch (comp.getOcciComponentState().getValue()) {
case Status.ACTIVE_VALUE:
comp.stop();
cmtool.undeploy(comp);
comp.setOcciComponentState(Status.UNDEPLOYED);
break;
case Status.INACTIVE_VALUE:
cmtool.undeploy(comp);
comp.setOcciComponentState(Status.UNDEPLOYED);
break;
case Status.DEPLOYED_VALUE:
cmtool.undeploy(comp);
comp.setOcciComponentState(Status.UNDEPLOYED);
break;
case Status.ERROR_VALUE:
cmtool.undeploy(comp);
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:
for (Component component : getInstallDependendComps()) {
component.deploy();
}
status = cmtool.deploy(comp);
if (status == 0 && assertCompsStatusEquals(getInstallDependendComps(), Status.DEPLOYED)) {
comp.setOcciComponentState(Status.DEPLOYED);
} else {
comp.setOcciComponentState(Status.ERROR);
}
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:
for (Component component : getInstallDependendComps()) {
component.configure();
}
status = cmtool.configure(comp);
if (status == 0 && assertCompsStatusEquals(getInstallDependendComps(), Status.INACTIVE)) {
comp.setOcciComponentState(Status.INACTIVE);
} else {
comp.setOcciComponentState(Status.ERROR);
}
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:
for (Component component : getExecutionDependendComps()) {
component.start();
}
status = cmtool.start(comp);
if (status == 0 && assertCompsStatusEquals(getExecutionDependendComps(), Status.ACTIVE)) {
comp.setOcciComponentState(Status.ACTIVE);
} else {
comp.setOcciComponentState(Status.ERROR);
}
break;
case Status.UNDEPLOYED_VALUE:
for (Component component : getInstallDependendComps()) {
component.deploy();
}
comp.deploy();
for (Component component : getInstallDependendComps()) {
component.configure();
}
comp.configure();
for (Component component : getExecutionDependendComps()) {
component.start();
}
status = cmtool.start(comp);
if (status == 0 && assertCompsStatusEquals(getExecutionDependendComps(), Status.ACTIVE)) {
comp.setOcciComponentState(Status.ACTIVE);
} else {
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() {
// Component State Machine.
switch (comp.getOcciComponentState().getValue()) {
case Status.ACTIVE_VALUE:
cmtool.stop(comp);
comp.setOcciComponentState(Status.INACTIVE);
break;
default:
break;
}
}
// End of user code
private List<Component> getInstallDependendComps() {
LinkedList<Component> dependendComponents = new LinkedList<Component>();
for (Link link : comp.getLinks()) {
for (MixinBase mixin : link.getParts()) {
if (mixin instanceof Installationdependency) {
dependendComponents.add((Component) link.getTarget());
break;
}
}
}
return dependendComponents;
}
private List<Component> getExecutionDependendComps() {
LinkedList<Component> dependendComponents = new LinkedList<Component>();
for (Link link : comp.getLinks()) {
for (MixinBase mixin : link.getParts()) {
if (mixin instanceof Executiondependency) {
dependendComponents.add((Component) link.getTarget());
break;
}
}
}
return dependendComponents;
}
private boolean assertCompsStatusEquals(List<Component> components, Status status) {
for (Component component : components) {
if (component.getOcciComponentState().getValue() != status.getValue()) {
return false;
}
}
return true;
}
public static boolean isConnectedToCompute(Component comp) {
for (Link link : comp.getLinks()) {
if (link.getTarget() != null) {
if (link.getTarget() instanceof Compute) {
return true;
}
}
}
return false;
}
}
\ 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 Wed Dec 05 12:12:23 CET 2018 from platform:/resource/monitoring/model/monitoring.occie by org.eclipse.cmf.occi.core.gen.connector
* 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;
/**
* 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() {
......@@ -33,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() {
......@@ -44,36 +41,43 @@ 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() {
return new DataprocessorConnector();
}
/**
* EFactory method for OCCI kind: - scheme:
* http://schemas.ugoe.cs.rwm/monitoring# - term: publisher - title: Publisher
* Resource
*/
@Override
public monitoring.Processor createProcessor() {
return new ProcessorConnector();
public monitoring.Resultprovider createResultprovider() {
return new ResultproviderConnector();
}
/**
* 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: monitoringproperty - title:
* MonitoringProperty Component
*/
@Override
public monitoring.Publisher createPublisher() {
return new PublisherConnector();
public monitoring.Monitorableproperty createMonitorableproperty() {
return new MonitorablepropertyConnector();
}
/**
* EFactory method for OCCI kind:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring#
* - term: monitoringproperty
* - title: MonitoringProperty Mixin
* EFactory method for OCCI kind: - scheme:
* http://schemas.ugoe.cs.rwm/monitoring# - term: martpublisher - title:
* MartPublisher Mixin
*/
@Override
public monitoring.Monitoringproperty createMonitoringproperty() {
return new MonitoringpropertyConnector();
public monitoring.Occiresultprovider createOcciresultprovider() {
return new OcciresultproviderConnector();
}
}
/**
* 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
* Generated at Wed Dec 19 11:10:50 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.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.
*/
private static Logger LOGGER = LoggerFactory.getLogger(DatagathererConnector.class);
private ComponentManager compMan;
// Start of user code Datagathererconnector_constructor
/**
* Constructs a datagatherer connector.
*/
DatagathererConnector()
{
DatagathererConnector() {
LOGGER.debug("Constructor called on " + this);
this.compMan = new ComponentManager(this);
// TODO: Implement this constructor.
}
// End of user code
//
// 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 +60,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 +71,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,10 +82,12 @@ 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.
if (ComponentManager.isConnectedToCompute(this)) {
this.stop();
this.undeploy();
}
}
// End of user code
......@@ -98,82 +95,74 @@ public class DatagathererConnector extends monitoring.impl.DatagathererImpl
// Datagatherer actions.
//
// Start of user code Datagatherer_Kind_undeploy_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: undeploy
* - title:
*/
@Override
public void undeploy()
{
LOGGER.debug("Action undeploy() called on " + this);
// TODO: Implement how to undeploy this datagatherer.
}
// 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);
compMan.deploy();
// TODO: Implement how to deploy this datagatherer.
}
// End of user code
// Start of user code Datagatherer_Kind_configure_action
// Start of user code Datagatherer_Kind_Stop_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: stop -
* title: Stop the application.
*/
@Override
public void configure()
{
LOGGER.debug("Action configure() called on " + this);
// TODO: Implement how to configure this datagatherer.
public void stop() {
LOGGER.debug("Action stop() called on " + this);
compMan.stop();
// TODO: Implement how to stop this datagatherer.
}
// 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);
compMan.start();
// TODO: Implement how to start this datagatherer.
}
// End of user code
// Start of user code Datagatherer_Kind_Stop_action
// Start of user code Datagatherer_Kind_configure_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: configure
* - title:
*/
@Override
public void stop()
{
LOGGER.debug("Action stop() called on " + this);
public void configure() {
LOGGER.debug("Action configure() called on " + this);
compMan.configure();
// TODO: Implement how to configure this datagatherer.
}
// TODO: Implement how to stop this datagatherer.
// 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:
*/
@Override
public void undeploy() {
LOGGER.debug("Action undeploy() called on " + this);
compMan.undeploy();
// TODO: Implement how to undeploy this datagatherer.
}
// 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 05 12:12:23 CET 2018 from platform:/resource/monitoring/model/monitoring.occie by org.eclipse.cmf.occi.core.gen.connector
* Generated at Wed Dec 19 11:10:50 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.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 ProcessorConnector extends monitoring.impl.ProcessorImpl
{
public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl {
/**
* Initialize the logger.
*/
private static Logger LOGGER = LoggerFactory.getLogger(ProcessorConnector.class);
private static Logger LOGGER = LoggerFactory.getLogger(DataprocessorConnector.class);
private ComponentManager compMan;
// Start of user code Processorconnector_constructor
/**
* Constructs a processor connector.
*/
ProcessorConnector()
{
DataprocessorConnector() {
LOGGER.debug("Constructor called on " + this);
this.compMan = new ComponentManager(this);
// TODO: Implement this constructor.
}
// End of user code
//
// 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.
}
......@@ -63,8 +60,7 @@ public class ProcessorConnector extends monitoring.impl.ProcessorImpl
* 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.
}
......@@ -75,8 +71,7 @@ public class ProcessorConnector extends monitoring.impl.ProcessorImpl
* 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.
}
......@@ -87,10 +82,12 @@ public class ProcessorConnector extends monitoring.impl.ProcessorImpl
* 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.
if (ComponentManager.isConnectedToCompute(this)) {
this.stop();
this.undeploy();
}
}
// End of user code
......@@ -98,82 +95,75 @@ public class ProcessorConnector extends monitoring.impl.ProcessorImpl
// Processor actions.
//
// Start of user code Processor_Kind_undeploy_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: undeploy
* - title:
*/
@Override
public void undeploy()
{
LOGGER.debug("Action undeploy() called on " + this);
// TODO: Implement how to undeploy this processor.
}
// 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);
compMan.deploy();
// TODO: Implement how to deploy this processor.
}
// End of user code
// Start of user code Processor_Kind_configure_action
// Start of user code Processor_Kind_Stop_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: stop -
* title: Stop the application.
*/
@Override
public void configure()
{
LOGGER.debug("Action configure() called on " + this);
public void stop() {
LOGGER.debug("Action stop() called on " + this);
compMan.stop();
// TODO: Implement how to configure this processor.
// TODO: Implement how to stop this processor.
}
// 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()
{
public void start() {
LOGGER.debug("Action start() called on " + this);
compMan.start();
// TODO: Implement how to start this processor.
}
// End of user code
// Start of user code Processor_Kind_Stop_action
// Start of user code Processor_Kind_configure_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: configure
* - title:
*/
@Override
public void stop()
{
LOGGER.debug("Action stop() called on " + this);
public void configure() {
LOGGER.debug("Action configure() called on " + this);
compMan.configure();
// TODO: Implement how to configure this processor.
}
// TODO: Implement how to stop this processor.
// 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:
*/
@Override
public void undeploy() {
LOGGER.debug("Action undeploy() called on " + this);
compMan.undeploy();
// TODO: Implement how to undeploy this processor.
}
// 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 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
*/
public class MonitorablepropertyConnector extends monitoring.impl.MonitorablepropertyImpl {
/**
* Initialize the logger.
*/
private static Logger LOGGER = LoggerFactory.getLogger(MonitorablepropertyConnector.class);
// Start of user code Monitoringpropertyconnector_constructor
/**
* Constructs a monitoringproperty connector.
*/
MonitorablepropertyConnector() {
LOGGER.debug("Constructor called on " + this);
// TODO: Implement this constructor.
}
// End of user code
//
// OCCI CRUD callback operations.
//
// Start of user code MonitoringpropertyocciCreate
/**
* Called when this Monitoringproperty instance is completely created.
*/
@Override
public void occiCreate() {
LOGGER.debug("occiCreate() called on " + this);
// TODO: Implement this callback or remove this method.
}
// End of user code
// Start of user code Monitoringproperty_occiRetrieve_method
/**
* Called when this Monitoringproperty instance must be retrieved.
*/
@Override
public void occiRetrieve() {
LOGGER.debug("occiRetrieve() called on " + this);
// TODO: Implement this callback or remove this method.
}
// End of user code
// Start of user code Monitoringproperty_occiUpdate_method
/**
* Called when this Monitoringproperty instance is completely updated.
*/
@Override
public void occiUpdate() {
LOGGER.debug("occiUpdate() called on " + this);
// TODO: Implement this callback or remove this method.
}
// End of user code
// Start of user code MonitoringpropertyocciDelete_method
/**
* Called when this Monitoringproperty instance will be deleted.
*/
@Override
public void occiDelete() {
LOGGER.debug("occiDelete() called on " + this);
// TODO: Implement this callback or remove this method.
}
// End of user code
//
// 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 Dec 05 12:12:23 CET 2018 from platform:/resource/monitoring/model/monitoring.occie by org.eclipse.cmf.occi.core.gen.connector
* 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 Mixin
* Connector implementation for the OCCI kind: - scheme:
* http://schemas.ugoe.cs.rwm/monitoring# - term: martpublisher - title:
* MartPublisher Mixin
*/
public class MonitoringpropertyConnector extends monitoring.impl.MonitoringpropertyImpl
{
public class OcciresultproviderConnector extends monitoring.impl.OcciresultproviderImpl {
/**
* Initialize the logger.
*/
private static Logger LOGGER = LoggerFactory.getLogger(MonitoringpropertyConnector.class);
private static Logger LOGGER = LoggerFactory.getLogger(OcciresultproviderConnector.class);
// Start of user code Monitoringpropertyconnector_constructor
// Start of user code Martpublisherconnector_constructor
/**
* Constructs a monitoringproperty connector.
* Constructs a martpublisher connector.
*/
MonitoringpropertyConnector()
{
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 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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Connector implementation for the OCCI kind:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring#
* - term: publisher
* - title: Publisher Resource
*/
public class PublisherConnector extends monitoring.impl.PublisherImpl
{
/**
* Initialize the logger.
*/
private static Logger LOGGER = LoggerFactory.getLogger(PublisherConnector.class);
// Start of user code Publisherconnector_constructor
/**
* Constructs a publisher connector.
*/
PublisherConnector()
{
LOGGER.debug("Constructor called on " + this);
// TODO: Implement this constructor.
}
// 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()
{
LOGGER.debug("occiCreate() called on " + this);
// TODO: Implement this callback or remove this method.
}
// End of user code
// Start of user code Publisher_occiRetrieve_method
/**
* Called when this Publisher instance must be retrieved.
*/
@Override
public void occiRetrieve()
{
LOGGER.debug("occiRetrieve() called on " + this);
// TODO: Implement this callback or remove this method.
}
// End of user code
// Start of user code Publisher_occiUpdate_method
/**
* Called when this Publisher instance is completely updated.
*/
@Override
public void occiUpdate()
{
LOGGER.debug("occiUpdate() called on " + this);
// TODO: Implement this callback or remove this method.
}
// End of user code
// Start of user code PublisherocciDelete_method
/**
* Called when this Publisher instance will be deleted.
*/
@Override
public void occiDelete()
{
LOGGER.debug("occiDelete() called on " + this);
// TODO: Implement this callback or remove this method.
}
// End of user code
//
// Publisher actions.
//
// Start of user code Publisher_Kind_undeploy_action
/**
* Implement OCCI action:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action#
* - term: undeploy
* - title:
*/
@Override
public void undeploy()
{
LOGGER.debug("Action undeploy() called on " + this);
// TODO: Implement how to undeploy 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:
*/
@Override
public void deploy()
{
LOGGER.debug("Action deploy() called on " + this);
// TODO: Implement how to deploy this publisher.
}
// 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:
*/
@Override
public void configure()
{
LOGGER.debug("Action configure() called on " + this);
// TODO: Implement how to configure this publisher.
}
// 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.
*/
@Override
public void start()
{
LOGGER.debug("Action start() called on " + this);
// TODO: Implement how to start this publisher.
}
// 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.
*/
@Override
public void stop()
{
LOGGER.debug("Action stop() called on " + this);
// TODO: Implement how to stop this publisher.
}
// 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 "";
}
}
connection.project.dir=..
connection.project.dir=../de.ugoe.cs.rwm.mocci.connector.dummy
eclipse.preferences.version=1