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 1377 additions and 546 deletions
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.Dataprocessor;
import monitoring.Monitorableproperty;
import monitoring.Sensor;
public class DataprocessorTest {
ConnectorFactory fac = new ConnectorFactory();
PlatformFactory pFac = PlatformFactory.eINSTANCE;
@BeforeClass
public static void OCCIRegistrySetup() {
TestUtility.extensionRegistrySetup();
}
@Test
public void occiCreateDataprocessor() {
Dataprocessor dp = fac.createDataprocessor();
dp.occiCreate();
assertTrue(true);
}
@Test
public void getDataprocessorInactive() {
Dataprocessor dp = createDataprocessor(Status.UNDEPLOYED);
Monitorableproperty monProp = getMonProp(getSensor(dp));
assertTrue(monProp.getMonitoringResult() == null);
dp.occiRetrieve();
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
assertTrue(monProp.getMonitoringResult() == null);
}
@Test
public void DataprocessorLifecycleToStart() {
Dataprocessor dp = createDataprocessor(Status.UNDEPLOYED);
dp.deploy();
assertTrue(inState(dp, Status.DEPLOYED));
dp.configure();
assertTrue(inState(dp, Status.INACTIVE));
dp.start();
assertTrue(inState(dp, Status.ACTIVE));
}
@Test
public void DataprocessorLifecycleToUndeployed() {
Dataprocessor dp = createDataprocessor(Status.ACTIVE);
dp.stop();
assertTrue(inState(dp, Status.INACTIVE));
dp.undeploy();
assertTrue(inState(dp, Status.UNDEPLOYED));
Dataprocessor rp2 = createDataprocessor(Status.DEPLOYED);
rp2.undeploy();
assertTrue(inState(dp, Status.UNDEPLOYED));
}
@Test
public void DataprocessorLifecycleDeployToUndeployed() {
Dataprocessor dp = createDataprocessor(Status.DEPLOYED);
dp.undeploy();
assertTrue(inState(dp, Status.UNDEPLOYED));
}
@Test
public void DataprocessorLifecycleActiveToUndeploy() {
Dataprocessor dp = createDataprocessor(Status.UNDEPLOYED);
dp.start();
dp.undeploy();
assertTrue(inState(dp, Status.UNDEPLOYED));
}
@Test
public void DataprocessorLifecycleActiveToStop() {
Dataprocessor dp = createDataprocessor(Status.UNDEPLOYED);
dp.start();
dp.stop();
assertTrue(inState(dp, Status.INACTIVE));
dp.start();
assertTrue(inState(dp, Status.ACTIVE));
}
@Test
public void occiDataprocessorRequests() {
Dataprocessor dp = createDataprocessor(Status.UNDEPLOYED);
dp.occiCreate();
dp.occiRetrieve();
dp.occiUpdate();
dp.occiDelete();
assertTrue(true);
}
private Boolean inState(Dataprocessor dp, Status deployed) {
return dp.getOcciComponentState().getValue() == deployed.getValue();
}
private Sensor getSensor(Dataprocessor dp) {
for (Link link : dp.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 Dataprocessor createDataprocessor(Status state) {
Sensor sens = fac.createSensor();
Dataprocessor dp = fac.createDataprocessor();
dp.setOcciComponentState(state);
Componentlink cLink = pFac.createComponentlink();
cLink.setSource(sens);
cLink.setTarget(dp);
Compute vm = InfrastructureFactory.eINSTANCE.createCompute();
Monitorableproperty monProp = fac.createMonitorableproperty();
monProp.setSource(sens);
monProp.setTarget(vm);
monProp.setMonitoringProperty("CPU");
return dp;
}
}
package de.ugoe.cs.rwm.mocci.connector.dummy;
import static org.junit.Assert.assertEquals;
import java.util.Properties;
import org.junit.Test;
import de.ugoe.cs.rwm.mocci.connector.ResultproviderHelper;
public class HelperTest {
@Test
public void testGetProperties() {
ResultproviderHelper helper = new ResultproviderHelper();
Properties props = helper.getProperties();
assertEquals("None,Low,Medium,High,Critical,3000", props.getProperty("CPU"));
}
}
package de.ugoe.cs.rwm.mocci.connector.dummy;
import static org.junit.Assert.assertTrue;
import org.junit.BeforeClass;
import org.junit.Test;
import org.modmacao.occi.platform.PlatformFactory;
import de.ugoe.cs.rwm.mocci.connector.ConnectorFactory;
import monitoring.Monitorableproperty;
public class MonitorablepropertyTest {
ConnectorFactory fac = new ConnectorFactory();
PlatformFactory pFac = PlatformFactory.eINSTANCE;
@BeforeClass
public static void OCCIRegistrySetup() {
TestUtility.extensionRegistrySetup();
}
@Test
public void occiDataprocessorRequests() {
Monitorableproperty monprop = fac.createMonitorableproperty();
monprop.occiCreate();
monprop.occiRetrieve();
monprop.occiUpdate();
monprop.occiDelete();
assertTrue(true);
}
}
package de.ugoe.cs.rwm.mocci.connector.dummy;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.lang.reflect.Field;
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 de.ugoe.cs.rwm.mocci.connector.ResultproviderConnector;
import monitoring.Monitorableproperty;
import monitoring.Occiresultprovider;
import monitoring.Resultprovider;
import monitoring.Sensor;
public class ResultproviderTest {
ConnectorFactory fac = new ConnectorFactory();
PlatformFactory pFac = PlatformFactory.eINSTANCE;
@BeforeClass
public static void OCCIRegistrySetup() {
TestUtility.extensionRegistrySetup();
}
@Test(expected = NoSuchElementException.class)
public void startSimulationWithoutSensor() {
Resultprovider rp = fac.createResultprovider();
rp.start();
}
@Test
public void startSimulationWithSensor() {
Resultprovider rp = createResultprovider(Status.UNDEPLOYED);
Monitorableproperty monProp = getMonProp(getSensor(rp));
assertTrue(monProp.getMonitoringResult() == null);
rp.start();
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
assertFalse(monProp.getMonitoringResult().contains(","));
}
@Test
public void startSimulationWithSensorQuotes() {
Resultprovider rp = createResultprovider(Status.UNDEPLOYED);
Monitorableproperty monProp = getMonProp(getSensor(rp));
monProp.setMonitoringProperty("MecoTaskResultForEach");
assertTrue(monProp.getMonitoringResult() == null);
rp.start();
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
assertTrue(monProp.getMonitoringResult().contains(","));
}
@Test
public void occiCreateResultprovider() {
Resultprovider rp = fac.createResultprovider();
rp.occiCreate();
assertTrue(true);
}
@Test
public void getResultproviderActiveState() {
Resultprovider rp = createResultprovider(Status.UNDEPLOYED);
rp.setOcciComponentState(Status.ACTIVE);
Monitorableproperty monProp = getMonProp(getSensor(rp));
assertTrue(monProp.getMonitoringResult() == null);
rp.occiRetrieve();
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
assertTrue(monProp.getMonitoringResult() != null);
}
@Test
public void getResultproviderInactive() {
Resultprovider rp = createResultprovider(Status.UNDEPLOYED);
Monitorableproperty monProp = getMonProp(getSensor(rp));
assertTrue(monProp.getMonitoringResult() == null);
rp.occiRetrieve();
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
assertTrue(monProp.getMonitoringResult() == null);
}
@Test
public void stopResultproviderInactive() {
Resultprovider rp = createResultprovider(Status.UNDEPLOYED);
rp.start();
Thread t = getSimulationThread(rp);
assertTrue(t.isAlive());
rp.occiDelete();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
assertFalse(t.isAlive());
}
@Test
public void ResultproviderLifecycleToStart() {
Resultprovider rp = createResultprovider(Status.UNDEPLOYED);
rp.deploy();
assertTrue(inState(rp, Status.DEPLOYED));
rp.configure();
assertTrue(inState(rp, Status.INACTIVE));
rp.start();
assertTrue(inState(rp, Status.ACTIVE));
}
@Test
public void ResultproviderLifecycleToUndeployed() {
Resultprovider rp = createResultprovider(Status.ACTIVE);
rp.stop();
assertTrue(inState(rp, Status.INACTIVE));
rp.undeploy();
assertTrue(inState(rp, Status.UNDEPLOYED));
Resultprovider rp2 = createResultprovider(Status.DEPLOYED);
rp2.undeploy();
assertTrue(inState(rp, Status.UNDEPLOYED));
}
@Test
public void ResultproviderLifecycleDeployToUndeployed() {
Resultprovider rp = createResultprovider(Status.DEPLOYED);
rp.undeploy();
assertTrue(inState(rp, Status.UNDEPLOYED));
}
@Test
public void ResultproviderLifecycleActiveToUndeploy() {
Resultprovider rp = createResultprovider(Status.UNDEPLOYED);
rp.start();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Thread t = getSimulationThread(rp);
assertTrue(t.isAlive());
rp.undeploy();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
assertFalse(t.isAlive());
assertTrue(inState(rp, Status.UNDEPLOYED));
}
@Test
public void ResultproviderLifecycleActiveToStop() {
Resultprovider rp = createResultprovider(Status.UNDEPLOYED);
rp.start();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Thread t = getSimulationThread(rp);
assertTrue(t.isAlive());
rp.stop();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
assertFalse(t.isAlive());
assertTrue(inState(rp, Status.INACTIVE));
rp.start();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Thread newT = getSimulationThread(rp);
assertTrue(newT.isAlive());
assertTrue(inState(rp, Status.ACTIVE));
}
@Test
public void occiRequestsResultprovider() {
Resultprovider rp = createResultprovider(Status.UNDEPLOYED);
rp.occiCreate();
rp.occiRetrieve();
rp.occiUpdate();
rp.occiDelete();
assertTrue(true);
}
@Test
public void occiResultproviderRequests() {
Resultprovider rp = createResultprovider(Status.UNDEPLOYED);
Occiresultprovider orp = fac.createOcciresultprovider();
rp.getParts().add(orp);
assertTrue(true);
}
private Boolean inState(Resultprovider rp, Status deployed) {
return rp.getOcciComponentState().getValue() == deployed.getValue();
}
private Thread getSimulationThread(Resultprovider rp) {
Class<ResultproviderConnector> rpc = ResultproviderConnector.class;
Field f = null;
try {
f = rpc.getDeclaredField("simulation");
f.setAccessible(true);
return (Thread) f.get(rp);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
assertTrue(false);
}
throw new NoSuchElementException("Simulation thread could not be found!");
}
private Sensor getSensor(Resultprovider rp) {
for (Link link : rp.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 Resultprovider createResultprovider(Status state) {
Sensor sens = fac.createSensor();
Resultprovider rp = fac.createResultprovider();
rp.setOcciComponentState(state);
Componentlink cLink = pFac.createComponentlink();
cLink.setSource(sens);
cLink.setTarget(rp);
Compute vm = InfrastructureFactory.eINSTANCE.createCompute();
Monitorableproperty monProp = fac.createMonitorableproperty();
monProp.setSource(sens);
monProp.setTarget(vm);
monProp.setMonitoringProperty("CPU");
return rp;
}
}
package de.ugoe.cs.rwm.mocci.connector.dummy;
import static org.junit.Assert.assertTrue;
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.Component;
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.Dataprocessor;
import monitoring.Monitorableproperty;
import monitoring.Resultprovider;
import monitoring.Sensor;
public class SensorTest {
ConnectorFactory fac = new ConnectorFactory();
PlatformFactory pFac = PlatformFactory.eINSTANCE;
@BeforeClass
public static void OCCIRegistrySetup() {
TestUtility.extensionRegistrySetup();
}
@Test
public void startSensorLifecycleToStart() {
Sensor sens = createSensor(Status.UNDEPLOYED);
sens.deploy();
assertTrue(inState(sens, Status.DEPLOYED));
sens.configure();
assertTrue(inState(sens, Status.INACTIVE));
sens.start();
assertTrue(inState(sens, Status.ACTIVE));
}
@Test
public void startSensorLifecycleToUndeploy() {
Sensor sens = createSensor(Status.ACTIVE);
sens.stop();
assertTrue(inState(sens, Status.INACTIVE));
sens.undeploy();
assertTrue(inState(sens, Status.UNDEPLOYED));
}
@Test
public void stopSensorActiveToUndeploy() {
Sensor sens = createSensor(Status.ACTIVE);
sens.undeploy();
assertTrue(inState(sens, Status.UNDEPLOYED));
}
@Test
public void stopSensorUndeployToStart() {
Sensor sens = createSensor(Status.UNDEPLOYED);
sens.start();
assertTrue(inState(sens, Status.ACTIVE));
}
@Test
public void startSensorDeployToUndeploy() {
Sensor sens = createSensor(Status.DEPLOYED);
sens.undeploy();
assertTrue(inState(sens, Status.UNDEPLOYED));
}
@Test
public void occiSensorRequests() {
Sensor sens = createSensor(Status.UNDEPLOYED);
sens.occiCreate();
sens.occiRetrieve();
sens.occiUpdate();
sens.occiDelete();
assertTrue(true);
}
private Boolean inState(Sensor sens, Status state) {
System.out.println(sens.getOcciAppState());
if (sens.getOcciAppState().getValue() != state.getValue()) {
return false;
}
for (Link link : sens.getLinks()) {
if (link instanceof Componentlink) {
Component comp = (Component) link.getTarget();
System.out.println(comp.getOcciComponentState());
if ((comp.getOcciComponentState().getValue() == state.getValue()) == false) {
return false;
}
}
}
return true;
}
private Sensor createSensor(Status state) {
Sensor sens = fac.createSensor();
sens.setOcciAppState(state);
Resultprovider rp = fac.createResultprovider();
rp.setOcciComponentState(state);
rp.setOcciComponentState(state);
Componentlink cLink = pFac.createComponentlink();
cLink.setSource(sens);
cLink.setTarget(rp);
Compute vm = InfrastructureFactory.eINSTANCE.createCompute();
Monitorableproperty monProp = fac.createMonitorableproperty();
monProp.setSource(sens);
monProp.setTarget(vm);
monProp.setMonitoringProperty("CPU");
Datagatherer dg = fac.createDatagatherer();
dg.setOcciComponentState(state);
Componentlink cLink2 = pFac.createComponentlink();
cLink2.setSource(sens);
cLink2.setTarget(dg);
Dataprocessor dp = fac.createDataprocessor();
dp.setOcciComponentState(state);
Componentlink cLink3 = pFac.createComponentlink();
cLink3.setSource(sens);
cLink3.setTarget(dp);
return sens;
}
}
package de.ugoe.cs.rwm.mocci.connector.dummy;
import org.eclipse.cmf.occi.core.OCCIPackage;
import org.eclipse.cmf.occi.core.util.OcciRegistry;
import org.eclipse.cmf.occi.infrastructure.InfrastructurePackage;
import org.modmacao.occi.platform.PlatformPackage;
import monitoring.MonitoringPackage;
public class TestUtility {
public static void extensionRegistrySetup() {
InfrastructurePackage.eINSTANCE.eClass();
OCCIPackage.eINSTANCE.eClass();
PlatformPackage.eINSTANCE.eClass();
MonitoringPackage.eINSTANCE.eClass();
OcciRegistry.getInstance().registerExtension("http://schemas.modmacao.org/occi/platform#",
PlatformPackage.class.getClassLoader().getResource("model/platform.occie").toString());
OcciRegistry.getInstance().registerExtension("http://schemas.ogf.org/occi/infrastructure#",
InfrastructurePackage.class.getClassLoader().getResource("model/Infrastructure.occie").toString());
OcciRegistry.getInstance().registerExtension("http://schemas.ogf.org/occi/core#",
OCCIPackage.class.getClassLoader().getResource("model/Core.occie").toString());
OcciRegistry.getInstance().registerExtension("http://schemas.ugoe.cs.rwm/monitoring#",
MonitoringPackage.class.getClassLoader().getResource("model/monitoring.occie").toString());
}
}
# Monitoring Extension Connector Dummy # Monitoring Connector
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). 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.
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. As the elements of the monitoring extension mainly inherit from elements of the enhanced platform extension provided by [MoDMaCAO](https://github.com/occiware/MoDMaCAO), the implementation of the lifecycle actions is quite similar. To handle the management of each individual component of a sensor, configuration management scripts have to be attached to them. Thus, in comparison to the [dummy connector](https://gitlab.gwdg.de/rwm/de.ugoe.cs.rwm.mocci/tree/master/de.ugoe.cs.rwm.mocci.connector.dummy), this connector allows for an actual deployment and management of sensors in a cloud environment. The skeleton for the connector of the OCCI monitoring extension is generated using [OCCI-Studio](https://github.com/occiware/OCCI-Studio).
As the elements of the monitoring extension mainly inherit from elements of the enhanced platform extension provided by [MoDMaCAO](https://github.com/occiware/MoDMaCAO), the implementation of the lifecycle actions is quite similar. To handle the management of each individual component of a sensor, configuration management scripts have to be attached to them.
## Attaching Configuration Management Scripts ## Attaching Configuration Management Scripts
...@@ -16,5 +15,4 @@ actions as described in the configuration management script called glances, loca ...@@ -16,5 +15,4 @@ actions as described in the configuration management script called glances, loca
![Attachment](./example.jpg "Attachment") ![Attachment](./example.jpg "Attachment")
*Note:* Currently, MoDMaCAO only provides a connector for [ansible](https://docs.ansible.com/).
// 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 { dependencies {
//Require-Bundle: org.eclipse.core.runtime,
// org.eclipse.emf.ecore;visibility:=reexport,
//org.eclipse.ocl.examples.codegen;visibility:=reexport,
//Nexus //Nexus
compile group: 'org.eclipse.ocl', name: 'pivot', version: '1.3.0' 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 //occiware
compile group: 'org.eclipse.cmf.occi', name: 'core', version: '1.0.0' 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.occi', name: 'platform', version: '1.0.0'
compile group: 'org.modmacao', name: 'cm', version: '1.0.0' compile group: 'org.modmacao', name: 'cm', version: '1.0.0'
compile group: 'org.modmacao', name: 'core', 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: 'org.modmacao.core', name: 'connector', version: '1.0.0'
compile group: 'commons-io', name: 'commons-io', version: '2.6' compile group: 'commons-io', name: 'commons-io', version: '2.6'
//maven //maven
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25' 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' compile group: 'org.eclipse.emf', name: 'org.eclipse.emf.ecore.xmi', version: '2.15.0'
testCompile group: 'junit', name: 'junit', version: '4.12' testCompile group: 'junit', name: 'junit', version: '4.12'
} }
...@@ -52,27 +21,32 @@ sourceSets { ...@@ -52,27 +21,32 @@ sourceSets {
main { main {
java { java {
srcDir 'src-gen' srcDir 'src-gen'
}
//output.classesDir = "$workDir/client/program"
} }
//output.classesDir = "$workDir/client/program"
} }
}
processResources { processResources {
from("."){ from(".") {
include("plugin.xml") include("plugin.xml")
} include("mocci.properties")
}
} }
uploadArchives { uploadArchives {
repositories { repositories {
mavenDeployer { mavenDeployer {
repository(url: "https://nexus.informatik.uni-goettingen.de/content/repositories/rwm/") { repository(url: "https://nexus.informatik.uni-goettingen.de/content/repositories/rwm/") {
authentication(userName: System.getenv('NEXUSUSER'), password: System.getenv('NEXUSPASSWORD')) authentication(userName: System.getenv('NEXUSUSER'), password: System.getenv('NEXUSPASSWORD'))
} }
pom.version = "1.0.0" if (System.getenv('VERSION') != null) {
pom.artifactId = "connector" pom.version = System.getenv('VERSION')
pom.groupId = "de.ugoe.cs.rwm.mocci" println "Version is set to: " + System.getenv('VERSION')
} }
pom.version = "SNAPSHOT"
pom.artifactId = "connector"
pom.groupId = "de.ugoe.cs.rwm.mocci"
}
} }
} }
default_endpoint=172.19.0.1:8080
\ No newline at end of file
...@@ -5,6 +5,7 @@ import java.util.List; ...@@ -5,6 +5,7 @@ import java.util.List;
import org.eclipse.cmf.occi.core.Link; import org.eclipse.cmf.occi.core.Link;
import org.eclipse.cmf.occi.core.MixinBase; import org.eclipse.cmf.occi.core.MixinBase;
import org.eclipse.cmf.occi.infrastructure.Compute;
import org.modmacao.cm.ConfigurationManagementTool; import org.modmacao.cm.ConfigurationManagementTool;
import org.modmacao.cm.ansible.AnsibleCMTool; import org.modmacao.cm.ansible.AnsibleCMTool;
import org.modmacao.occi.platform.Component; import org.modmacao.occi.platform.Component;
...@@ -15,211 +16,206 @@ import modmacao.Installationdependency; ...@@ -15,211 +16,206 @@ import modmacao.Installationdependency;
public class ComponentManager { public class ComponentManager {
private ConfigurationManagementTool cmtool = new AnsibleCMTool(); private ConfigurationManagementTool cmtool = new AnsibleCMTool();
private Component comp; private Component comp;
public ComponentManager(Component comp) { public ComponentManager(Component comp) {
this.comp = comp; this.comp = comp;
} }
public void undeploy() { public void undeploy() {
switch(comp.getOcciComponentState().getValue()) { switch (comp.getOcciComponentState().getValue()) {
case Status.ACTIVE_VALUE:
comp.stop();
cmtool.undeploy(comp);
comp.setOcciComponentState(Status.UNDEPLOYED);
break;
case Status.INACTIVE_VALUE: case Status.ACTIVE_VALUE:
cmtool.undeploy(comp);
comp.setOcciComponentState(Status.UNDEPLOYED);
break;
comp.stop();
cmtool.undeploy(comp);
comp.setOcciComponentState(Status.UNDEPLOYED);
break;
case Status.DEPLOYED_VALUE: case Status.INACTIVE_VALUE:
cmtool.undeploy(comp); cmtool.undeploy(comp);
comp.setOcciComponentState(Status.UNDEPLOYED); comp.setOcciComponentState(Status.UNDEPLOYED);
break; break;
case Status.DEPLOYED_VALUE:
cmtool.undeploy(comp);
comp.setOcciComponentState(Status.UNDEPLOYED);
break;
case Status.ERROR_VALUE: case Status.ERROR_VALUE:
cmtool.undeploy(comp); cmtool.undeploy(comp);
comp.setOcciComponentState(Status.UNDEPLOYED); comp.setOcciComponentState(Status.UNDEPLOYED);
break; break;
default: default:
break; break;
} }
} }
// End of user code // End of user code
// 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:
*/ */
public void deploy() public void deploy() {
{
int status = -1; int status = -1;
// Component State Machine. // Component State Machine.
switch(comp.getOcciComponentState().getValue()) { switch (comp.getOcciComponentState().getValue()) {
case Status.UNDEPLOYED_VALUE: case Status.UNDEPLOYED_VALUE:
for (Component component: getInstallDependendComps()) { for (Component component : getInstallDependendComps()) {
component.deploy(); component.deploy();
} }
status = cmtool.deploy(comp); status = cmtool.deploy(comp);
if (status == 0 && assertCompsStatusEquals(getInstallDependendComps(), Status.DEPLOYED)) if (status == 0 && assertCompsStatusEquals(getInstallDependendComps(), Status.DEPLOYED)) {
comp.setOcciComponentState(Status.DEPLOYED); comp.setOcciComponentState(Status.DEPLOYED);
else } else {
comp.setOcciComponentState(Status.ERROR); comp.setOcciComponentState(Status.ERROR);
}
break; break;
default: default:
break; break;
} }
} }
// 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:
*/ */
public void configure() public void configure() {
{
int status = -1; int status = -1;
// Component State Machine. // Component State Machine.
switch(comp.getOcciComponentState().getValue()) { switch (comp.getOcciComponentState().getValue()) {
case Status.DEPLOYED_VALUE: case Status.DEPLOYED_VALUE:
for (Component component: getInstallDependendComps()) { for (Component component : getInstallDependendComps()) {
component.configure(); component.configure();
} }
status = cmtool.configure(comp); status = cmtool.configure(comp);
if (status == 0 && assertCompsStatusEquals(getInstallDependendComps(), Status.INACTIVE)) if (status == 0 && assertCompsStatusEquals(getInstallDependendComps(), Status.INACTIVE)) {
comp.setOcciComponentState(Status.INACTIVE); comp.setOcciComponentState(Status.INACTIVE);
else } else {
comp.setOcciComponentState(Status.ERROR); comp.setOcciComponentState(Status.ERROR);
}
break; break;
default: default:
break; break;
} }
} }
// 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.
*/ */
public void start() public void start() {
{
int status = -1; int status = -1;
// Component State Machine. // Component State Machine.
switch(comp.getOcciComponentState().getValue()) { switch (comp.getOcciComponentState().getValue()) {
case Status.INACTIVE_VALUE: case Status.INACTIVE_VALUE:
for (Component component: getExecutionDependendComps()) { for (Component component : getExecutionDependendComps()) {
component.start(); component.start();
} }
status = cmtool.start(comp); status = cmtool.start(comp);
if (status == 0 && assertCompsStatusEquals(getExecutionDependendComps(), Status.ACTIVE)) if (status == 0 && assertCompsStatusEquals(getExecutionDependendComps(), Status.ACTIVE)) {
comp.setOcciComponentState(Status.ACTIVE); comp.setOcciComponentState(Status.ACTIVE);
else } else {
comp.setOcciComponentState(Status.ERROR); comp.setOcciComponentState(Status.ERROR);
}
break;
break;
case Status.UNDEPLOYED_VALUE: case Status.UNDEPLOYED_VALUE:
for (Component component: getInstallDependendComps()) { for (Component component : getInstallDependendComps()) {
component.deploy(); component.deploy();
} }
comp.deploy(); comp.deploy();
for (Component component: getInstallDependendComps()) { for (Component component : getInstallDependendComps()) {
component.configure(); component.configure();
} }
comp.configure(); comp.configure();
for (Component component: getExecutionDependendComps()) { for (Component component : getExecutionDependendComps()) {
component.start(); component.start();
} }
status = cmtool.start(comp); status = cmtool.start(comp);
if (status == 0 && assertCompsStatusEquals(getExecutionDependendComps(), Status.ACTIVE)) if (status == 0 && assertCompsStatusEquals(getExecutionDependendComps(), Status.ACTIVE)) {
comp.setOcciComponentState(Status.ACTIVE); comp.setOcciComponentState(Status.ACTIVE);
else } else {
comp.setOcciComponentState(Status.ERROR); comp.setOcciComponentState(Status.ERROR);
}
break;
default: default:
break; break;
} }
} }
// 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.
*/ */
public void stop() public void stop() {
{
int status = -1;
// Component State Machine. // Component State Machine.
switch(comp.getOcciComponentState().getValue()) { switch (comp.getOcciComponentState().getValue()) {
case Status.ACTIVE_VALUE: case Status.ACTIVE_VALUE:
status = cmtool.stop(comp); cmtool.stop(comp);
comp.setOcciComponentState(Status.INACTIVE); comp.setOcciComponentState(Status.INACTIVE);
break; break;
default: default:
break; break;
} }
} }
// End of user code // End of user code
private List<Component> getInstallDependendComps(){ private List<Component> getInstallDependendComps() {
LinkedList<Component> dependendComponents = new LinkedList<Component>(); LinkedList<Component> dependendComponents = new LinkedList<Component>();
for (Link link: comp.getLinks()) { for (Link link : comp.getLinks()) {
for (MixinBase mixin: link.getParts()) { for (MixinBase mixin : link.getParts()) {
if (mixin instanceof Installationdependency) { if (mixin instanceof Installationdependency) {
dependendComponents.add((Component) link.getTarget()); dependendComponents.add((Component) link.getTarget());
break; break;
} }
} }
} }
return dependendComponents; return dependendComponents;
} }
private List<Component> getExecutionDependendComps(){ private List<Component> getExecutionDependendComps() {
LinkedList<Component> dependendComponents = new LinkedList<Component>(); LinkedList<Component> dependendComponents = new LinkedList<Component>();
for (Link link: comp.getLinks()) { for (Link link : comp.getLinks()) {
for (MixinBase mixin: link.getParts()) { for (MixinBase mixin : link.getParts()) {
if (mixin instanceof Executiondependency) { if (mixin instanceof Executiondependency) {
dependendComponents.add((Component) link.getTarget()); dependendComponents.add((Component) link.getTarget());
break; break;
...@@ -228,14 +224,24 @@ public class ComponentManager { ...@@ -228,14 +224,24 @@ public class ComponentManager {
} }
return dependendComponents; return dependendComponents;
} }
private boolean assertCompsStatusEquals(List<Component> components, Status status) { private boolean assertCompsStatusEquals(List<Component> components, Status status) {
for (Component component: components) { for (Component component : components) {
if (component.getOcciComponentState().getValue() != status.getValue()) { if (component.getOcciComponentState().getValue() != status.getValue()) {
return false; return false;
} }
} }
return true; return true;
} }
} public static boolean isConnectedToCompute(Component comp) {
\ No newline at end of file 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 * 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 Jan 02 16:14:48 CET 2019 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;
/** /**
* Connector EFactory for the OCCI extension: * Connector EFactory for the OCCI extension: - name: monitoring - scheme:
* - name: monitoring * http://schemas.ugoe.cs.rwm/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: * EFactory method for OCCI kind: - scheme:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring# * http://schemas.ugoe.cs.rwm/monitoring# - term: sensor - title: Sensor
* - term: sensor * Component
* - title: Sensor Component
*/ */
@Override @Override
public monitoring.Sensor createSensor() { public monitoring.Sensor createSensor() {
...@@ -33,10 +31,9 @@ public class ConnectorFactory extends monitoring.impl.MonitoringFactoryImpl ...@@ -33,10 +31,9 @@ public class ConnectorFactory extends monitoring.impl.MonitoringFactoryImpl
} }
/** /**
* EFactory method for OCCI kind: * EFactory method for OCCI kind: - scheme:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring# * http://schemas.ugoe.cs.rwm/monitoring# - term: datagatherer - title:
* - term: datagatherer * DataGatherer Resource
* - title: DataGatherer Resource
*/ */
@Override @Override
public monitoring.Datagatherer createDatagatherer() { public monitoring.Datagatherer createDatagatherer() {
...@@ -44,10 +41,9 @@ public class ConnectorFactory extends monitoring.impl.MonitoringFactoryImpl ...@@ -44,10 +41,9 @@ public class ConnectorFactory extends monitoring.impl.MonitoringFactoryImpl
} }
/** /**
* EFactory method for OCCI kind: * EFactory method for OCCI kind: - scheme:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring# * http://schemas.ugoe.cs.rwm/monitoring# - term: processor - title: Processor
* - term: processor * Resource
* - title: Processor Resource
*/ */
@Override @Override
public monitoring.Dataprocessor createDataprocessor() { public monitoring.Dataprocessor createDataprocessor() {
...@@ -55,10 +51,9 @@ public class ConnectorFactory extends monitoring.impl.MonitoringFactoryImpl ...@@ -55,10 +51,9 @@ public class ConnectorFactory extends monitoring.impl.MonitoringFactoryImpl
} }
/** /**
* EFactory method for OCCI kind: * EFactory method for 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
*/ */
@Override @Override
public monitoring.Resultprovider createResultprovider() { public monitoring.Resultprovider createResultprovider() {
...@@ -66,10 +61,9 @@ public class ConnectorFactory extends monitoring.impl.MonitoringFactoryImpl ...@@ -66,10 +61,9 @@ public class ConnectorFactory extends monitoring.impl.MonitoringFactoryImpl
} }
/** /**
* EFactory method for OCCI kind: * EFactory method for OCCI kind: - scheme:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring# * http://schemas.ugoe.cs.rwm/monitoring# - term: monitoringproperty - title:
* - term: monitoringproperty * MonitoringProperty Component
* - title: MonitoringProperty Component
*/ */
@Override @Override
public monitoring.Monitorableproperty createMonitorableproperty() { public monitoring.Monitorableproperty createMonitorableproperty() {
...@@ -77,10 +71,9 @@ public class ConnectorFactory extends monitoring.impl.MonitoringFactoryImpl ...@@ -77,10 +71,9 @@ public class ConnectorFactory extends monitoring.impl.MonitoringFactoryImpl
} }
/** /**
* EFactory method for OCCI kind: * EFactory method for OCCI kind: - scheme:
* - scheme: http://schemas.ugoe.cs.rwm/monitoring# * http://schemas.ugoe.cs.rwm/monitoring# - term: martpublisher - title:
* - term: martpublisher * MartPublisher Mixin
* - title: MartPublisher Mixin
*/ */
@Override @Override
public monitoring.Occiresultprovider createOcciresultprovider() { public monitoring.Occiresultprovider createOcciresultprovider() {
......
/** /**
* 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 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: datagatherer - title:
* - term: datagatherer * DataGatherer Resource
* - title: DataGatherer Resource
*/ */
public class DatagathererConnector extends monitoring.impl.DatagathererImpl public class DatagathererConnector extends monitoring.impl.DatagathererImpl {
{
/** /**
* Initialize the logger. * Initialize the logger.
*/ */
private static Logger LOGGER = LoggerFactory.getLogger(DatagathererConnector.class); private static Logger LOGGER = LoggerFactory.getLogger(DatagathererConnector.class);
private ComponentManager compMan; private ComponentManager compMan;
// Start of user code Datagathererconnector_constructor // Start of user code Datagathererconnector_constructor
/** /**
* Constructs a datagatherer connector. * Constructs a datagatherer connector.
*/ */
DatagathererConnector() DatagathererConnector() {
{
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. // TODO: Implement this constructor.
...@@ -46,14 +43,13 @@ public class DatagathererConnector extends monitoring.impl.DatagathererImpl ...@@ -46,14 +43,13 @@ public class DatagathererConnector extends monitoring.impl.DatagathererImpl
// //
// OCCI CRUD callback operations. // OCCI CRUD callback operations.
// //
// Start of user code DatagathererocciCreate // Start of user code DatagathererocciCreate
/** /**
* Called when this Datagatherer instance is completely created. * Called when this Datagatherer instance is completely created.
*/ */
@Override @Override
public void occiCreate() public void occiCreate() {
{
LOGGER.debug("occiCreate() called on " + this); LOGGER.debug("occiCreate() called on " + this);
// TODO: Implement this callback or remove this method. // TODO: Implement this callback or remove this method.
} }
...@@ -64,8 +60,7 @@ public class DatagathererConnector extends monitoring.impl.DatagathererImpl ...@@ -64,8 +60,7 @@ public class DatagathererConnector extends monitoring.impl.DatagathererImpl
* Called when this Datagatherer instance must be retrieved. * Called when this Datagatherer 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.
} }
...@@ -76,8 +71,7 @@ public class DatagathererConnector extends monitoring.impl.DatagathererImpl ...@@ -76,8 +71,7 @@ public class DatagathererConnector extends monitoring.impl.DatagathererImpl
* Called when this Datagatherer instance is completely updated. * Called when this Datagatherer 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.
} }
...@@ -88,10 +82,12 @@ public class DatagathererConnector extends monitoring.impl.DatagathererImpl ...@@ -88,10 +82,12 @@ public class DatagathererConnector extends monitoring.impl.DatagathererImpl
* Called when this Datagatherer instance will be deleted. * Called when this Datagatherer 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
...@@ -101,80 +97,72 @@ public class DatagathererConnector extends monitoring.impl.DatagathererImpl ...@@ -101,80 +97,72 @@ public class DatagathererConnector extends monitoring.impl.DatagathererImpl
// Start of user code Datagatherer_Kind_deploy_action // Start of user code Datagatherer_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 datagatherer. // TODO: Implement how to deploy this datagatherer.
} }
// End of user code // End of user code
// Start of user code Datagatherer_Kind_Stop_action // Start of user code Datagatherer_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 datagatherer. // TODO: Implement how to stop this datagatherer.
} }
// End of user code // End of user code
// Start of user code Datagatherer_Kind_Start_action // Start of user code Datagatherer_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() {
{
LOGGER.debug("Action start() called on " + this); LOGGER.debug("Action start() called on " + this);
compMan.start(); compMan.start();
// TODO: Implement how to start this datagatherer. // TODO: Implement how to start this datagatherer.
} }
// End of user code // End of user code
// Start of user code Datagatherer_Kind_configure_action // Start of user code Datagatherer_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 datagatherer. // TODO: Implement how to configure this datagatherer.
} }
// End of user code // End of user code
// Start of user code Datagatherer_Kind_undeploy_action // Start of user code Datagatherer_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 datagatherer. // TODO: Implement how to undeploy this datagatherer.
} }
// 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 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: processor - title: Processor
* - term: processor * Resource
* - title: Processor Resource
*/ */
public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl {
{
/** /**
* Initialize the logger. * Initialize the logger.
*/ */
private static Logger LOGGER = LoggerFactory.getLogger(DataprocessorConnector.class); private static Logger LOGGER = LoggerFactory.getLogger(DataprocessorConnector.class);
private ComponentManager compMan; private ComponentManager compMan;
// Start of user code Processorconnector_constructor // Start of user code Processorconnector_constructor
/** /**
* Constructs a processor connector. * Constructs a processor connector.
*/ */
DataprocessorConnector() DataprocessorConnector() {
{
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. // TODO: Implement this constructor.
...@@ -46,14 +43,13 @@ public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl ...@@ -46,14 +43,13 @@ public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl
// //
// OCCI CRUD callback operations. // OCCI CRUD callback operations.
// //
// Start of user code ProcessorocciCreate // Start of user code ProcessorocciCreate
/** /**
* Called when this Processor instance is completely created. * Called when this Processor instance is completely created.
*/ */
@Override @Override
public void occiCreate() public void occiCreate() {
{
LOGGER.debug("occiCreate() called on " + this); LOGGER.debug("occiCreate() called on " + this);
// TODO: Implement this callback or remove this method. // TODO: Implement this callback or remove this method.
} }
...@@ -64,8 +60,7 @@ public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl ...@@ -64,8 +60,7 @@ public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl
* Called when this Processor instance must be retrieved. * Called when this Processor 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.
} }
...@@ -76,8 +71,7 @@ public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl ...@@ -76,8 +71,7 @@ public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl
* Called when this Processor instance is completely updated. * Called when this Processor 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.
} }
...@@ -88,10 +82,12 @@ public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl ...@@ -88,10 +82,12 @@ public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl
* Called when this Processor instance will be deleted. * Called when this Processor 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
...@@ -101,81 +97,73 @@ public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl ...@@ -101,81 +97,73 @@ public class DataprocessorConnector extends monitoring.impl.DataprocessorImpl
// Start of user code Processor_Kind_deploy_action // Start of user code Processor_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 processor. // TODO: Implement how to deploy this processor.
} }
// End of user code // End of user code
// Start of user code Processor_Kind_Stop_action // Start of user code Processor_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 processor. // TODO: Implement how to stop this processor.
} }
// End of user code // End of user code
// Start of user code Processor_Kind_Start_action // Start of user code Processor_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() {
{
LOGGER.debug("Action start() called on " + this); LOGGER.debug("Action start() called on " + this);
compMan.start(); compMan.start();
// TODO: Implement how to start this processor. // TODO: Implement how to start this processor.
} }
// End of user code // End of user code
// Start of user code Processor_Kind_configure_action // Start of user code Processor_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 processor. // TODO: Implement how to configure this processor.
} }
// End of user code // End of user code
// Start of user code Processor_Kind_undeploy_action // Start of user code Processor_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 processor. // TODO: Implement how to undeploy this processor.
} }
// 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 Jan 02 16:14:48 CET 2019 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: monitoringproperty - title:
* - term: monitoringproperty * MonitoringProperty Component
* - title: MonitoringProperty Component
*/ */
public class MonitorablepropertyConnector extends monitoring.impl.MonitorablepropertyImpl public class MonitorablepropertyConnector extends monitoring.impl.MonitorablepropertyImpl {
{
/** /**
* Initialize the logger. * Initialize the logger.
*/ */
...@@ -36,8 +33,7 @@ public class MonitorablepropertyConnector extends monitoring.impl.Monitorablepro ...@@ -36,8 +33,7 @@ public class MonitorablepropertyConnector extends monitoring.impl.Monitorablepro
/** /**
* Constructs a monitoringproperty connector. * Constructs a monitoringproperty connector.
*/ */
MonitorablepropertyConnector() MonitorablepropertyConnector() {
{
LOGGER.debug("Constructor called on " + this); LOGGER.debug("Constructor called on " + this);
// TODO: Implement this constructor. // TODO: Implement this constructor.
} }
...@@ -45,14 +41,13 @@ public class MonitorablepropertyConnector extends monitoring.impl.Monitorablepro ...@@ -45,14 +41,13 @@ public class MonitorablepropertyConnector extends monitoring.impl.Monitorablepro
// //
// OCCI CRUD callback operations. // OCCI CRUD callback operations.
// //
// Start of user code MonitoringpropertyocciCreate // Start of user code MonitoringpropertyocciCreate
/** /**
* Called when this Monitoringproperty instance is completely created. * Called when this Monitoringproperty instance is completely created.
*/ */
@Override @Override
public void occiCreate() public void occiCreate() {
{
LOGGER.debug("occiCreate() called on " + this); LOGGER.debug("occiCreate() called on " + this);
// TODO: Implement this callback or remove this method. // TODO: Implement this callback or remove this method.
} }
...@@ -63,8 +58,7 @@ public class MonitorablepropertyConnector extends monitoring.impl.Monitorablepro ...@@ -63,8 +58,7 @@ public class MonitorablepropertyConnector extends monitoring.impl.Monitorablepro
* Called when this Monitoringproperty instance must be retrieved. * Called when this Monitoringproperty 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.
} }
...@@ -75,8 +69,7 @@ public class MonitorablepropertyConnector extends monitoring.impl.Monitorablepro ...@@ -75,8 +69,7 @@ public class MonitorablepropertyConnector extends monitoring.impl.Monitorablepro
* Called when this Monitoringproperty instance is completely updated. * Called when this Monitoringproperty 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.
} }
...@@ -87,8 +80,7 @@ public class MonitorablepropertyConnector extends monitoring.impl.Monitorablepro ...@@ -87,8 +80,7 @@ public class MonitorablepropertyConnector extends monitoring.impl.Monitorablepro
* Called when this Monitoringproperty instance will be deleted. * Called when this Monitoringproperty 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. // TODO: Implement this callback or remove this method.
} }
...@@ -98,7 +90,4 @@ public class MonitorablepropertyConnector extends monitoring.impl.Monitorablepro ...@@ -98,7 +90,4 @@ public class MonitorablepropertyConnector extends monitoring.impl.Monitorablepro
// Monitoringproperty actions. // 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 Jan 02 16:14:48 CET 2019 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: martpublisher * MartPublisher Mixin
* - title: MartPublisher Mixin
*/ */
public class OcciresultproviderConnector extends monitoring.impl.OcciresultproviderImpl public class OcciresultproviderConnector extends monitoring.impl.OcciresultproviderImpl {
{
/** /**
* Initialize the logger. * Initialize the logger.
*/ */
...@@ -36,15 +33,10 @@ public class OcciresultproviderConnector extends monitoring.impl.Occiresultprovi ...@@ -36,15 +33,10 @@ public class OcciresultproviderConnector extends monitoring.impl.Occiresultprovi
/** /**
* Constructs a martpublisher connector. * Constructs a martpublisher connector.
*/ */
OcciresultproviderConnector() 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.LinkedList;
import java.util.List; import java.util.List;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import org.eclipse.cmf.occi.core.AttributeState; import org.eclipse.cmf.occi.core.*;
import org.eclipse.cmf.occi.core.Configuration;
import org.eclipse.cmf.occi.core.Link;
import org.eclipse.cmf.occi.core.MixinBase;
import org.eclipse.cmf.occi.core.OCCIFactory;
import org.eclipse.cmf.occi.core.Resource;
import org.eclipse.cmf.occi.core.impl.OCCIFactoryImpl; 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.Monitorableproperty;
import monitoring.Occiresultprovider; import monitoring.Occiresultprovider;
import monitoring.Sensor; import monitoring.Sensor;
import monitoring.impl.MonitoringFactoryImpl;
/** /**
* 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 ResultproviderConnector extends monitoring.impl.ResultproviderImpl public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl {
{
/** /**
* Initialize the logger. * Initialize the logger.
*/ */
...@@ -53,32 +45,37 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl ...@@ -53,32 +45,37 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl
private Monitorableproperty monProp; private Monitorableproperty monProp;
private Resource monObject; private Resource monObject;
private List<AttributeState> workaround = new LinkedList<AttributeState>(); 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.
*/ */
ResultproviderConnector() ResultproviderConnector() {
{
LOGGER.debug("Constructor called on " + this); LOGGER.debug("Constructor called on " + this);
this.compMan = new ComponentManager(this); this.compMan = new ComponentManager(this);
} }
// 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
...@@ -88,8 +85,7 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl ...@@ -88,8 +85,7 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl
* 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.
} }
...@@ -100,8 +96,7 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl ...@@ -100,8 +96,7 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl
* 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.
} }
...@@ -112,10 +107,12 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl ...@@ -112,10 +107,12 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl
* 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
...@@ -125,44 +122,40 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl ...@@ -125,44 +122,40 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl
// 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(); setRuntimeInformation();
System.out.println(this.attributes); System.out.println(this.attributes);
LOGGER.debug("Action start() called on " + this); LOGGER.debug("Action start() called on " + this);
...@@ -170,43 +163,39 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl ...@@ -170,43 +163,39 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl
removeRuntimeInformation(); removeRuntimeInformation();
System.out.println(this.attributes); 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() { private MixinBase getMartMixin() {
for(MixinBase mixinBase: this.getParts()) { for (MixinBase mixinBase : this.getParts()) {
if(mixinBase instanceof Occiresultprovider) { if (mixinBase instanceof Occiresultprovider) {
LOGGER.info("MartPublisher Mixin found for Publisher:" + this.title); LOGGER.info("MartPublisher Mixin found for Publisher:" + this.title);
return mixinBase; return mixinBase;
} }
...@@ -216,14 +205,14 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl ...@@ -216,14 +205,14 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl
private List<Monitorableproperty> getMonitoringProperties(Sensor sens) { private List<Monitorableproperty> getMonitoringProperties(Sensor sens) {
LinkedList<Monitorableproperty> monProps = new LinkedList<Monitorableproperty>(); LinkedList<Monitorableproperty> monProps = new LinkedList<Monitorableproperty>();
for(Link link: sens.getLinks()) { for (Link link : sens.getLinks()) {
if(link instanceof Monitorableproperty) { if (link instanceof Monitorableproperty) {
monProps.add((Monitorableproperty) link); monProps.add((Monitorableproperty) link);
} }
} }
return monProps; return monProps;
} }
private void setRuntimeInformation() { private void setRuntimeInformation() {
sensor = getSensor(); sensor = getSensor();
AttributeState sensorAttr = factory.createAttributeState(); AttributeState sensorAttr = factory.createAttributeState();
...@@ -232,7 +221,7 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl ...@@ -232,7 +221,7 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl
System.out.println("Sensor: " + sensor); System.out.println("Sensor: " + sensor);
this.attributes.add(sensorAttr); this.attributes.add(sensorAttr);
workaround.add(sensorAttr); workaround.add(sensorAttr);
monProp = getMonProp(sensor); monProp = getMonProp(sensor);
AttributeState monPropAttr = factory.createAttributeState(); AttributeState monPropAttr = factory.createAttributeState();
monPropAttr.setName("monitorable.property"); monPropAttr.setName("monitorable.property");
...@@ -240,13 +229,13 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl ...@@ -240,13 +229,13 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl
System.out.println("MonProp: " + monProp); System.out.println("MonProp: " + monProp);
this.attributes.add(monPropAttr); this.attributes.add(monPropAttr);
workaround.add(monPropAttr); workaround.add(monPropAttr);
AttributeState monPropNameAttr = factory.createAttributeState(); AttributeState monPropNameAttr = factory.createAttributeState();
monPropNameAttr.setName("monitorable.property.property"); monPropNameAttr.setName("monitorable.property.property");
monPropNameAttr.setValue(monProp.getMonitoringProperty()); monPropNameAttr.setValue(monProp.getMonitoringProperty());
this.attributes.add(monPropNameAttr); this.attributes.add(monPropNameAttr);
workaround.add(monPropNameAttr); workaround.add(monPropNameAttr);
monObject = monProp.getTarget(); monObject = monProp.getTarget();
AttributeState monObjectAttr = factory.createAttributeState(); AttributeState monObjectAttr = factory.createAttributeState();
monObjectAttr.setName("monitorable.property.target"); monObjectAttr.setName("monitorable.property.target");
...@@ -254,50 +243,94 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl ...@@ -254,50 +243,94 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl
this.attributes.add(monObjectAttr); this.attributes.add(monObjectAttr);
workaround.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() { private Sensor getSensor() {
for(Link link: this.getRlinks()) { for (Link link : this.getRlinks()) {
if(link.getSource() instanceof Sensor) { if (link.getSource() instanceof Sensor) {
return ((Sensor) link.getSource()); return ((Sensor) link.getSource());
} }
} }
throw new NoSuchElementException("No containing sensor found!"); throw new NoSuchElementException("No containing sensor found!");
} }
private Monitorableproperty getMonProp(Sensor sensor) { private Monitorableproperty getMonProp(Sensor sensor) {
for(Link link: sensor.getLinks()) { for (Link link : sensor.getLinks()) {
if(link instanceof Monitorableproperty) { if (link instanceof Monitorableproperty) {
return ((Monitorableproperty) link); return ((Monitorableproperty) link);
} }
} }
throw new NoSuchElementException("No monitorableproperty found in sensor!"); throw new NoSuchElementException("No monitorableproperty found in sensor!");
} }
private void removeRuntimeInformation() { private void removeRuntimeInformation() {
for(AttributeState work: workaround) { for (AttributeState work : workaround) {
this.attributes.remove(work); this.attributes.remove(work);
} }
}
}
private String getContainingSensorLocation() { private String getContainingSensorLocation() {
for(Link link: this.getRlinks()) { for (Link link : this.getRlinks()) {
if(link.getSource() instanceof Sensor) { if (link.getSource() instanceof Sensor) {
return link.getSource().getLocation(); return link.getSource().getLocation();
} }
} }
return "No containing sensor found"; return "No containing sensor found";
} }
private Sensor getContainingSensor() { private Sensor getContainingSensor() {
for(Link link: this.getRlinks()) { for (Link link : this.getRlinks()) {
if(link.getSource() instanceof Sensor) { if (link.getSource() instanceof Sensor) {
return (Sensor) link.getSource(); return (Sensor) link.getSource();
} }
} }
LOGGER.info("No containing Sensor found"); LOGGER.info("No containing Sensor found");
throw new NoSuchElementException(); throw new NoSuchElementException();
} }
} }
/*******************************************************************************
* 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