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 965 additions and 453 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
*/
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 * Copyright (c) 2016-2017 Inria
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* - Philippe Merle <philippe.merle@inria.fr> * - Philippe Merle <philippe.merle@inria.fr>
* - Faiez Zalila <faiez.zalila@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 * 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; package de.ugoe.cs.rwm.mocci.connector;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* Connector implementation for the OCCI kind: * Connector implementation for the OCCI kind: - scheme:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring# * http://schemas.ugoe.cs.rwm/monitoring# - term: martpublisher - title:
* - term: monitoringproperties * MartPublisher Mixin
* - title: MonitoringProperty Mixin
*/ */
public class MonitoringpropertiesConnector extends monitoring.impl.MonitoringpropertiesImpl public class OcciresultproviderConnector extends monitoring.impl.OcciresultproviderImpl {
{
/** /**
* Initialize the logger. * Initialize the logger.
*/ */
private static Logger LOGGER = LoggerFactory.getLogger(MonitoringpropertiesConnector.class); private static Logger LOGGER = LoggerFactory.getLogger(OcciresultproviderConnector.class);
// Start of user code Monitoringpropertiesconnector_constructor // Start of user code Martpublisherconnector_constructor
/** /**
* Constructs a monitoringproperties connector. * Constructs a martpublisher connector.
*/ */
MonitoringpropertiesConnector() OcciresultproviderConnector() {
{
LOGGER.debug("Constructor called on " + this); LOGGER.debug("Constructor called on " + this);
// TODO: Implement this constructor. // TODO: Implement this constructor.
} }
// End of user code // End of user code
}
}
/** /**
* Copyright (c) 2016-2017 Inria * Copyright (c) 2016-2017 Inria
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* - Philippe Merle <philippe.merle@inria.fr> * - Philippe Merle <philippe.merle@inria.fr>
* - Faiez Zalila <faiez.zalila@inria.fr> * - Faiez Zalila <faiez.zalila@inria.fr>
* *
* 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 * 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; 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.*;
import org.eclipse.cmf.occi.core.impl.OCCIFactoryImpl;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import de.ugoe.cs.rwm.mocci.connector.util.PropertiesHelper;
import monitoring.Monitorableproperty;
import monitoring.Occiresultprovider;
import monitoring.Sensor;
/** /**
* Connector implementation for the OCCI kind: * Connector implementation for the OCCI kind: - scheme:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring# * http://schemas.ugoe.cs.rwm/monitoring# - term: publisher - title: Publisher
* - term: publisher * Resource
* - title: Publisher Resource
*/ */
public class PublisherConnector extends monitoring.impl.PublisherImpl public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl {
{
/** /**
* Initialize the logger. * Initialize the logger.
*/ */
private static Logger LOGGER = LoggerFactory.getLogger(PublisherConnector.class); private OCCIFactoryImpl factory = new OCCIFactoryImpl();
private ComponentManager compMan; private static Logger LOGGER = LoggerFactory.getLogger(ResultproviderConnector.class);
private ComponentManager compMan;
private Sensor sensor;
private Monitorableproperty monProp;
private Resource monObject;
private List<AttributeState> workaround = new LinkedList<AttributeState>();
// Start of user code Publisherconnector_constructor // Start of user code Publisherconnector_constructor
/** /**
* Constructs a publisher connector. * Constructs a publisher connector.
*/ */
PublisherConnector() ResultproviderConnector() {
{
LOGGER.debug("Constructor called on " + this); LOGGER.debug("Constructor called on " + this);
this.compMan = new ComponentManager(this); this.compMan = new ComponentManager(this);
// TODO: Implement this constructor.
} }
// End of user code // End of user code
// //
// OCCI CRUD callback operations. // OCCI CRUD callback operations.
// //
// Start of user code PublisherocciCreate // Start of user code PublisherocciCreate
/** /**
* Called when this Publisher instance is completely created. * Called when this Publisher instance is completely created.
*/ */
@Override @Override
public void occiCreate() public void occiCreate() {
{
LOGGER.debug("occiCreate() called on " + this); LOGGER.debug("occiCreate() called on " + this);
// check for default provider endpoint
if (rspIsDefined() == false) {
MixinBase mixB = getMartMixin();
Occiresultprovider orp = (Occiresultprovider) mixB;
orp.setResultProviderEndpoint(getDefaultEndpoint());
getEndpointAttribute(orp).setValue(getDefaultEndpoint());
}
// TODO: Implement this callback or remove this method. // TODO: Implement this callback or remove this method.
} }
// End of user code // End of user code
...@@ -65,8 +85,7 @@ private ComponentManager compMan; ...@@ -65,8 +85,7 @@ private ComponentManager compMan;
* Called when this Publisher instance must be retrieved. * Called when this Publisher instance must be retrieved.
*/ */
@Override @Override
public void occiRetrieve() public void occiRetrieve() {
{
LOGGER.debug("occiRetrieve() called on " + this); LOGGER.debug("occiRetrieve() called on " + this);
// TODO: Implement this callback or remove this method. // TODO: Implement this callback or remove this method.
} }
...@@ -77,8 +96,7 @@ private ComponentManager compMan; ...@@ -77,8 +96,7 @@ private ComponentManager compMan;
* Called when this Publisher instance is completely updated. * Called when this Publisher instance is completely updated.
*/ */
@Override @Override
public void occiUpdate() public void occiUpdate() {
{
LOGGER.debug("occiUpdate() called on " + this); LOGGER.debug("occiUpdate() called on " + this);
// TODO: Implement this callback or remove this method. // TODO: Implement this callback or remove this method.
} }
...@@ -89,10 +107,12 @@ private ComponentManager compMan; ...@@ -89,10 +107,12 @@ private ComponentManager compMan;
* Called when this Publisher instance will be deleted. * Called when this Publisher instance will be deleted.
*/ */
@Override @Override
public void occiDelete() public void occiDelete() {
{
LOGGER.debug("occiDelete() called on " + this); 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 // End of user code
...@@ -102,80 +122,215 @@ private ComponentManager compMan; ...@@ -102,80 +122,215 @@ private ComponentManager compMan;
// Start of user code Publisher_Kind_deploy_action // Start of user code Publisher_Kind_deploy_action
/** /**
* Implement OCCI action: * Implement OCCI action: - scheme:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action# * http://schemas.modmacao.org/occi/platform/component/action# - term: deploy -
* - term: deploy * title:
* - title:
*/ */
@Override @Override
public void deploy() public void deploy() {
{
LOGGER.debug("Action deploy() called on " + this); LOGGER.debug("Action deploy() called on " + this);
compMan.deploy(); compMan.deploy();
// TODO: Implement how to deploy this publisher. // TODO: Implement how to deploy this publisher.
} }
// End of user code // End of user code
// Start of user code Publisher_Kind_Stop_action // Start of user code Publisher_Kind_Stop_action
/** /**
* Implement OCCI action: * Implement OCCI action: - scheme:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action# * http://schemas.modmacao.org/occi/platform/component/action# - term: stop -
* - term: stop * title: Stop the application.
* - title: Stop the application.
*/ */
@Override @Override
public void stop() public void stop() {
{
LOGGER.debug("Action stop() called on " + this); LOGGER.debug("Action stop() called on " + this);
compMan.stop(); compMan.stop();
// TODO: Implement how to stop this publisher. // TODO: Implement how to stop this publisher.
} }
// End of user code // End of user code
// Start of user code Publisher_Kind_Start_action // Start of user code Publisher_Kind_Start_action
/** /**
* Implement OCCI action: * Implement OCCI action: - scheme:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action# * http://schemas.modmacao.org/occi/platform/component/action# - term: start -
* - term: start * title: Start the application.
* - title: Start the application.
*/ */
@Override @Override
public void start() public void start() {
{ setRuntimeInformation();
System.out.println(this.attributes);
LOGGER.debug("Action start() called on " + this); LOGGER.debug("Action start() called on " + this);
compMan.start(); compMan.start();
// TODO: Implement how to start this publisher. removeRuntimeInformation();
System.out.println(this.attributes);
} }
// End of user code // End of user code
// Start of user code Publisher_Kind_configure_action // Start of user code Publisher_Kind_configure_action
/** /**
* Implement OCCI action: * Implement OCCI action: - scheme:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action# * http://schemas.modmacao.org/occi/platform/component/action# - term: configure
* - term: configure * - title:
* - title:
*/ */
@Override @Override
public void configure() public void configure() {
{
LOGGER.debug("Action configure() called on " + this); LOGGER.debug("Action configure() called on " + this);
compMan.configure(); compMan.configure();
// TODO: Implement how to configure this publisher. // TODO: Implement how to configure this publisher.
} }
// End of user code // End of user code
// Start of user code Publisher_Kind_undeploy_action // Start of user code Publisher_Kind_undeploy_action
/** /**
* Implement OCCI action: * Implement OCCI action: - scheme:
* - scheme: http://schemas.modmacao.org/occi/platform/component/action# * http://schemas.modmacao.org/occi/platform/component/action# - term: undeploy
* - term: undeploy * - title:
* - title:
*/ */
@Override @Override
public void undeploy() public void undeploy() {
{
LOGGER.debug("Action undeploy() called on " + this); LOGGER.debug("Action undeploy() called on " + this);
compMan.undeploy(); compMan.undeploy();
// TODO: Implement how to undeploy this publisher. // TODO: Implement how to undeploy this publisher.
} }
// End of user code // End of user code
private MixinBase getMartMixin() {
for (MixinBase mixinBase : this.getParts()) {
if (mixinBase instanceof Occiresultprovider) {
LOGGER.info("MartPublisher Mixin found for Publisher:" + this.title);
return mixinBase;
}
}
return null;
}
private List<Monitorableproperty> getMonitoringProperties(Sensor sens) {
LinkedList<Monitorableproperty> monProps = new LinkedList<Monitorableproperty>();
for (Link link : sens.getLinks()) {
if (link instanceof Monitorableproperty) {
monProps.add((Monitorableproperty) link);
}
}
return monProps;
}
private void setRuntimeInformation() {
sensor = getSensor();
AttributeState sensorAttr = factory.createAttributeState();
sensorAttr.setName("sensor");
sensorAttr.setValue(sensor.getLocation());
System.out.println("Sensor: " + sensor);
this.attributes.add(sensorAttr);
workaround.add(sensorAttr);
monProp = getMonProp(sensor);
AttributeState monPropAttr = factory.createAttributeState();
monPropAttr.setName("monitorable.property");
monPropAttr.setValue(monProp.getLocation());
System.out.println("MonProp: " + monProp);
this.attributes.add(monPropAttr);
workaround.add(monPropAttr);
} AttributeState monPropNameAttr = factory.createAttributeState();
monPropNameAttr.setName("monitorable.property.property");
monPropNameAttr.setValue(monProp.getMonitoringProperty());
this.attributes.add(monPropNameAttr);
workaround.add(monPropNameAttr);
monObject = monProp.getTarget();
AttributeState monObjectAttr = factory.createAttributeState();
monObjectAttr.setName("monitorable.property.target");
monObjectAttr.setValue(monObject.getLocation());
this.attributes.add(monObjectAttr);
workaround.add(monObjectAttr);
}
private AttributeState getEndpointAttribute(Occiresultprovider orp) {
for (AttributeState as : orp.getAttributes()) {
if (as.getName().equals("result.provider.endpoint")) {
return as;
}
}
AttributeState as = OCCIFactory.eINSTANCE.createAttributeState();
as.setName("result.provider.endpoint");
orp.getAttributes().add(as);
return as;
}
private boolean rspIsDefined() {
MixinBase mixB = getMartMixin();
if (mixB != null) {
Occiresultprovider orp = (Occiresultprovider) mixB;
if (orp.getResultProviderEndpoint() == null || orp.getResultProviderEndpoint().equals("")) {
return false;
}
for (AttributeState as : this.getAttributes()) {
if (as.getName().equals("occi.result.provider.endpoint")) {
if (as.getValue() == null || as.getValue().equals("")) {
return false;
}
}
}
for (AttributeState as : orp.getAttributes()) {
if (as.getName().equals("occi.result.provider.endpoint")) {
if (as.getValue() == null || as.getValue().equals("")) {
return false;
}
}
}
}
return true;
}
private String getDefaultEndpoint() {
String defaultEndpoint = new PropertiesHelper().getProperties().getProperty("default_endpoint");
if (defaultEndpoint == null || defaultEndpoint.equals("")) {
return "localhost";
}
System.out.println("Using default endpoint: " + defaultEndpoint);
return defaultEndpoint;
}
private Sensor getSensor() {
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) {
return ((Monitorableproperty) link);
}
}
throw new NoSuchElementException("No monitorableproperty found in sensor!");
}
private void removeRuntimeInformation() {
for (AttributeState work : workaround) {
this.attributes.remove(work);
}
}
private String getContainingSensorLocation() {
for (Link link : this.getRlinks()) {
if (link.getSource() instanceof Sensor) {
return link.getSource().getLocation();
}
}
return "No containing sensor found";
}
private Sensor getContainingSensor() {
for (Link link : this.getRlinks()) {
if (link.getSource() instanceof Sensor) {
return (Sensor) link.getSource();
}
}
LOGGER.info("No containing Sensor found");
throw new NoSuchElementException();
}
}
connection.project.dir=../de.ugoe.cs.rwm.mocci.connector connection.project.dir=../de.ugoe.cs.rwm.mocci.connector.dummy
eclipse.preferences.version=1 eclipse.preferences.version=1
de.ugoe.cs.rwm.mocci.model.edit/icons/full/obj16/Dataprocessor.gif

129 B

de.ugoe.cs.rwm.mocci.model.edit/icons/full/obj16/Gatheringservice.gif

129 B

de.ugoe.cs.rwm.mocci.model.edit/icons/full/obj16/Martpublisher.gif

129 B

de.ugoe.cs.rwm.mocci.model.edit/icons/full/obj16/Resultprovider.gif

129 B