Skip to content
Snippets Groups Projects
Commit bd4cb996 authored by erbel's avatar erbel
Browse files

Add properties file to set default provider endpoint to use

parent cd1cae31
No related branches found
No related tags found
No related merge requests found
Pipeline #159362 failed
......@@ -13,7 +13,8 @@
<module name="AvoidStarImport">
<property name="excludes" value="java.io,java.util,java.util.concurrent,com.google.common.graph,
org.apache.bcel.classfile,org.mongodb.morphia.annotations,de.ugoe.cs.comfort.data.models,
org.apache.bcel.generic,org.jacoco.core.data,com.github.javaparser.ast.stmt" />
org.apache.bcel.generic,org.jacoco.core.data,com.github.javaparser.ast.stmt,
org.eclipse.cmf.occi.core"/>
</module>
<module name="ConstantName"/>
<module name="EmptyBlock">
......@@ -41,12 +42,14 @@
<module name="LeftCurly"/>
<module name="RightCurly">
<property name="id" value="RightCurlySame"/>
<property name="tokens" value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_DO"/>
<property name="tokens"
value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_DO"/>
</module>
<module name="RightCurly">
<property name="id" value="RightCurlyAlone"/>
<property name="option" value="alone"/>
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT, INSTANCE_INIT"/>
<property name="tokens"
value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT, INSTANCE_INIT"/>
</module>
<module name="OneStatementPerLine"/>
......
......@@ -6,9 +6,9 @@ dependencies {
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: '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'
//maven
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile group: 'org.eclipse.emf', name: 'org.eclipse.emf.ecore', version: '2.15.0'
......@@ -21,31 +21,32 @@ sourceSets {
main {
java {
srcDir 'src-gen'
}
//output.classesDir = "$workDir/client/program"
}
//output.classesDir = "$workDir/client/program"
}
}
processResources {
from("."){
include("plugin.xml")
}
from(".") {
include("plugin.xml")
include("mocci.properties")
}
}
uploadArchives {
repositories {
mavenDeployer {
repository(url: "https://nexus.informatik.uni-goettingen.de/content/repositories/rwm/") {
authentication(userName: System.getenv('NEXUSUSER'), password: System.getenv('NEXUSPASSWORD'))
mavenDeployer {
repository(url: "https://nexus.informatik.uni-goettingen.de/content/repositories/rwm/") {
authentication(userName: System.getenv('NEXUSUSER'), password: System.getenv('NEXUSPASSWORD'))
}
if (System.getenv('VERSION') != null) {
pom.version = System.getenv('VERSION')
println "Version is set to: " + System.getenv('VERSION')
}
pom.version = "SNAPSHOT"
pom.artifactId = "connector"
pom.groupId = "de.ugoe.cs.rwm.mocci"
}
if (System.getenv('VERSION') != null) {
pom.version = System.getenv('VERSION')
println "Version is set to: " + System.getenv('VERSION')
}
pom.version = "SNAPSHOT"
pom.artifactId = "connector"
pom.groupId = "de.ugoe.cs.rwm.mocci"
}
}
}
default_endpoint=172.19.0.1:8080
\ No newline at end of file
......@@ -19,14 +19,12 @@ import java.util.LinkedList;
import java.util.List;
import java.util.NoSuchElementException;
import org.eclipse.cmf.occi.core.AttributeState;
import org.eclipse.cmf.occi.core.Link;
import org.eclipse.cmf.occi.core.MixinBase;
import org.eclipse.cmf.occi.core.Resource;
import org.eclipse.cmf.occi.core.*;
import org.eclipse.cmf.occi.core.impl.OCCIFactoryImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.ugoe.cs.rwm.mocci.connector.util.PropertiesHelper;
import monitoring.Monitorableproperty;
import monitoring.Occiresultprovider;
import monitoring.Sensor;
......@@ -70,6 +68,14 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl
@Override
public void occiCreate() {
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.
}
// End of user code
......@@ -238,6 +244,52 @@ public class ResultproviderConnector extends monitoring.impl.ResultproviderImpl
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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment