From e5ce63a019cebb4144f3e6d18ae07c6ae3058814 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Thu, 25 Jul 2019 15:15:55 +0000 Subject: [PATCH] Renamed project git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/vre-management/hello-world-se-plugin@181320 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 36 ++++++++ .project | 36 ++++++++ distro/LICENSE | 4 + distro/README | 66 ++++++++++++++ distro/changelog.xml | 23 +++++ distro/profile.xml | 28 ++++++ pom.xml | 72 ++++++++++++++++ .../org/acme/HWPluginStateNotification.java | 32 +++++++ src/main/java/org/acme/HelloWorldPlugin.java | 70 +++++++++++++++ .../org/acme/HelloWorldPluginDeclaration.java | 85 +++++++++++++++++++ ...nagement.executor.plugin.PluginDeclaration | 1 + 11 files changed, 453 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 distro/LICENSE create mode 100644 distro/README create mode 100644 distro/changelog.xml create mode 100644 distro/profile.xml create mode 100644 pom.xml create mode 100644 src/main/java/org/acme/HWPluginStateNotification.java create mode 100644 src/main/java/org/acme/HelloWorldPlugin.java create mode 100644 src/main/java/org/acme/HelloWorldPluginDeclaration.java create mode 100644 src/main/resources/META-INF/services/org.gcube.vremanagement.executor.plugin.PluginDeclaration diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..9d886d5 --- /dev/null +++ b/.classpath @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..cf197fc --- /dev/null +++ b/.project @@ -0,0 +1,36 @@ + + + helloworld-se-plugin + + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + org.eclipse.wst.common.project.facet.core.nature + + diff --git a/distro/LICENSE b/distro/LICENSE new file mode 100644 index 0000000..cdf50bd --- /dev/null +++ b/distro/LICENSE @@ -0,0 +1,4 @@ +gCube System - License +------------------------------------------------------------ + +${gcube.license} \ No newline at end of file diff --git a/distro/README b/distro/README new file mode 100644 index 0000000..1ade5fc --- /dev/null +++ b/distro/README @@ -0,0 +1,66 @@ +The gCube System - ${name} +-------------------------------------------------- + +${description} + + +${gcube.description} + +${gcube.funding} + + +Version +-------------------------------------------------- + +${version} (${buildDate}) + +Please see the file named "changelog.xml" in this directory for the release notes. + + +Authors +-------------------------------------------------- + +* Luca Frosini (luca.frosini-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy). + + +Maintainers +----------- + +* Luca Frosini (luca.frosini-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy). + + +Download information +-------------------------------------------------- + +Source code is available from SVN: + ${scm.url} + +Binaries can be downloaded from the gCube website: + ${gcube.website} + + +Installation +-------------------------------------------------- + +Installation documentation is available on-line in the gCube Wiki: + ${gcube.wikiRoot}/SmartExecutor + + +Documentation +-------------------------------------------------- + +Documentation is available on-line in the gCube Wiki: + ${gcube.wikiRoot}/SmartExecutor + + +Support +-------------------------------------------------- + +Bugs and support requests can be reported in the gCube issue tracking tool: + ${gcube.issueTracking} + + +Licensing +-------------------------------------------------- + +This software is licensed under the terms you may find in the file named "LICENSE" in this directory. diff --git a/distro/changelog.xml b/distro/changelog.xml new file mode 100644 index 0000000..2a99533 --- /dev/null +++ b/distro/changelog.xml @@ -0,0 +1,23 @@ + + + + + + + + Added code to use iteration number and uuid provided with smar-executor-api-1.5.0 (refs #6733) + Fixed input conversion from int to long to support Reminiscence (refs #772) + + + Cleaning Code + + + Cleaning code + + + Upgraded to new Plugin API + + + First Release + + \ No newline at end of file diff --git a/distro/profile.xml b/distro/profile.xml new file mode 100644 index 0000000..1e5db40 --- /dev/null +++ b/distro/profile.xml @@ -0,0 +1,28 @@ + + + + + Service + + ${description} + ${serviceClass} + ${artifactId} + 1.0.0 + + + ${description} + ${artifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + + Library + + ${build.finalName}.${project.packaging} + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..5e12773 --- /dev/null +++ b/pom.xml @@ -0,0 +1,72 @@ + + 4.0.0 + + org.gcube.tools + maven-parent + 1.0.0 + + + org.gcube + 1.0.0-SNAPSHOT + SmartExecutor-HelloWorldPlugin + Smart Executor Hello World Plugin + + + scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/vre-management/smart-executor-${project.artifactId} + scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/vre-management/smart-executor-${project.artifactId} + https://svn.d4science.research-infrastructures.eu/gcube/trunk/vre-management/smart-executor-${project.artifactId} + + + + + + org.gcube.distribution + gcube-bom + LATEST + pom + import + + + + + + UTF-8 + ${project.basedir}/distro + VREManagement + + + + + org.gcube.vremanagement + smart-executor-api + [1.5.0-SNAPSHOT, 2.0.0-SNAPSHOT) + provided + + + org.slf4j + slf4j-api + provided + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + make-uberjar + install + + + make-servicearchive + install + + + + + + helloworld-se-plugin + \ No newline at end of file diff --git a/src/main/java/org/acme/HWPluginStateNotification.java b/src/main/java/org/acme/HWPluginStateNotification.java new file mode 100644 index 0000000..379992d --- /dev/null +++ b/src/main/java/org/acme/HWPluginStateNotification.java @@ -0,0 +1,32 @@ +/** + * + */ +package org.acme; + +import java.util.Map; + +import org.gcube.vremanagement.executor.plugin.PluginStateEvolution; +import org.gcube.vremanagement.executor.plugin.PluginStateNotification; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Luca Frosini (ISTI - CNR) + * + */ +public class HWPluginStateNotification extends PluginStateNotification { + + private static Logger logger = LoggerFactory.getLogger(HWPluginStateNotification.class); + + public HWPluginStateNotification(Map inputs){ + super(inputs); + logger.debug("{} instantiated with provide inputs {}", HWPluginStateNotification.class, inputs); + } + + @Override + public void pluginStateEvolution(PluginStateEvolution pluginStateEvolution, Exception e) + throws Exception { + logger.debug("New PluginStateEvolution : {}. Provided inputs was {}. {}", pluginStateEvolution, inputs, e==null?"":e.getStackTrace()); + } + +} diff --git a/src/main/java/org/acme/HelloWorldPlugin.java b/src/main/java/org/acme/HelloWorldPlugin.java new file mode 100644 index 0000000..d0247ed --- /dev/null +++ b/src/main/java/org/acme/HelloWorldPlugin.java @@ -0,0 +1,70 @@ +package org.acme; + +import java.util.Map; + +import org.gcube.vremanagement.executor.exception.InputsNullException; +import org.gcube.vremanagement.executor.exception.InvalidInputsException; +import org.gcube.vremanagement.executor.plugin.Plugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +public class HelloWorldPlugin extends Plugin { + + /** + * Logger + */ + private static Logger logger = LoggerFactory.getLogger(HelloWorldPlugin.class); + + public static final String SLEEP_TIME = "sleepTime"; + + public HelloWorldPlugin(HelloWorldPluginDeclaration pluginDeclaration) { + super(pluginDeclaration); + logger.debug("contructor"); + } + + /**{@inheritDoc}*/ + @Override + public void launch(Map inputs) throws Exception { + logger.debug("My UUID is {}", uuid.toString()); + logger.debug("My iteration number is {}", iterationNumber); + + logger.debug("Launching HelloWorld"); + if(inputs == null){ + throw new InputsNullException(); + }else if(inputs.isEmpty() || !inputs.containsKey(SLEEP_TIME)){ + logger.debug("HelloWorld inputs {} are not valid", inputs); + throw new InvalidInputsException(); + } + + this.setPercentageEvolution(20); + logger.debug("{} - Inputs : {}", this.getClass().getSimpleName(), inputs); + + this.setPercentageEvolution(30); + + Long sleepTime; + Object sleepTimeObject = inputs.get(SLEEP_TIME); + if(sleepTimeObject instanceof Integer){ + sleepTime = new Long((Integer) sleepTimeObject); + }else if(sleepTimeObject instanceof Long){ + sleepTime = (Long) sleepTimeObject; + } else { + sleepTime = new Long(sleepTimeObject.toString()); + } + + Thread.sleep(sleepTime); + + this.setPercentageEvolution(90); + logger.debug("HelloWorld finished"); + } + + /**{@inheritDoc}*/ + @Override + protected void onStop() throws Exception { + logger.debug("onStop()"); + Thread.currentThread().interrupt(); + } + +} diff --git a/src/main/java/org/acme/HelloWorldPluginDeclaration.java b/src/main/java/org/acme/HelloWorldPluginDeclaration.java new file mode 100644 index 0000000..6b3f2dc --- /dev/null +++ b/src/main/java/org/acme/HelloWorldPluginDeclaration.java @@ -0,0 +1,85 @@ +/** + * + */ +package org.acme; + +import java.util.HashMap; +import java.util.Map; + +import org.gcube.vremanagement.executor.plugin.Plugin; +import org.gcube.vremanagement.executor.plugin.PluginDeclaration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Luca Frosini (ISTI - CNR) + * + */ +public class HelloWorldPluginDeclaration implements PluginDeclaration { + /** + * Logger + */ + private static Logger logger = LoggerFactory.getLogger(HelloWorldPlugin.class); + + /** + * Plugin name used by the Executor to retrieve this class + */ + public static final String NAME = "HelloWorld"; + + public static final String DESCRIPTION = "Hello World Description"; + + public static final String VERSION = "1.1.2"; + + /**{@inheritDoc}*/ + @Override + public void init() { + logger.debug(String.format("%s initialized", HelloWorldPlugin.class.getSimpleName())); + } + + /**{@inheritDoc}*/ + @Override + public String getName() { + return NAME; + } + + /**{@inheritDoc}*/ + @Override + public String getDescription() { + return DESCRIPTION; + } + + /**{@inheritDoc}*/ + @Override + public String getVersion() { + return VERSION; + } + + /**{@inheritDoc}*/ + @Override + public Map getSupportedCapabilities() { + Map discoveredCapabilities = new HashMap(); + discoveredCapabilities.put("FakeKey", "FakeValue"); + return discoveredCapabilities; + } + + /**{@inheritDoc}*/ + @Override + public Class> getPluginImplementation() { + return HelloWorldPlugin.class; + } + + @Override + public String toString(){ + return String.format("{" + + "name:%s," + + "version:%s," + + "description:%s," + + "pluginImplementation:%s," + + "}", + getName(), + getVersion(), + getDescription(), + getPluginImplementation().getClass().getSimpleName()); + } + +} diff --git a/src/main/resources/META-INF/services/org.gcube.vremanagement.executor.plugin.PluginDeclaration b/src/main/resources/META-INF/services/org.gcube.vremanagement.executor.plugin.PluginDeclaration new file mode 100644 index 0000000..41162b5 --- /dev/null +++ b/src/main/resources/META-INF/services/org.gcube.vremanagement.executor.plugin.PluginDeclaration @@ -0,0 +1 @@ +org.acme.HelloWorldPluginDeclaration \ No newline at end of file