Switching to new smart-executor-api
This commit is contained in:
parent
f33ef3152f
commit
4cf5cb68dc
|
@ -0,0 +1,4 @@
|
|||
groupId=${groupId}
|
||||
artifactId=${artifactId}
|
||||
version=${version}
|
||||
description=${description}
|
|
@ -48,7 +48,7 @@ import org.xml.sax.InputSource;
|
|||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class ResourceCheckerPlugin extends Plugin<ResourceCheckerPluginDeclaration>{
|
||||
public class ResourceCheckerPlugin extends Plugin {
|
||||
|
||||
private static final int SECONDS2WAIT = 2; // seconds to wait among IS requests
|
||||
private static final String INITIAL_ERRORS_STATEMENT = "Other errors: ";
|
||||
|
@ -57,8 +57,7 @@ public class ResourceCheckerPlugin extends Plugin<ResourceCheckerPluginDeclarati
|
|||
private static final Logger logger = LoggerFactory.getLogger(ResourceCheckerPlugin.class);
|
||||
private static final DiscoveryClient client = ICFactory.client();
|
||||
|
||||
public ResourceCheckerPlugin(ResourceCheckerPluginDeclaration pluginDeclaration){
|
||||
super(pluginDeclaration);
|
||||
public ResourceCheckerPlugin(){
|
||||
logger.info("Constructor invoked");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.informationsystem.resource_checker;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* The resource-checker-se-plugin declaration class.
|
||||
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||
*/
|
||||
public class ResourceCheckerPluginDeclaration implements PluginDeclaration {
|
||||
|
||||
/**
|
||||
* Logger
|
||||
*/
|
||||
private static Logger logger = LoggerFactory.getLogger(ResourceCheckerPluginDeclaration.class);
|
||||
|
||||
/**
|
||||
* Plugin name used by the Executor to retrieve this class
|
||||
*/
|
||||
public static final String NAME = "resource-checker-se-plugin";
|
||||
public static final String DESCRIPTION = "The resource-checker-plugin has the role to check the existence of some resources in all Infrastructure's contexts.";
|
||||
public static final String VERSION = "1.1.0";
|
||||
|
||||
/**{@inheritDoc}*/
|
||||
@Override
|
||||
public void init() {
|
||||
logger.debug(String.format("%s initialized", ResourceCheckerPluginDeclaration.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<String, String> getSupportedCapabilities() {
|
||||
Map<String, String> discoveredCapabilities = new HashMap<String, String>();
|
||||
// No capabilities to discover
|
||||
return discoveredCapabilities;
|
||||
}
|
||||
|
||||
/**{@inheritDoc}*/
|
||||
@Override
|
||||
public Class<? extends Plugin<? extends PluginDeclaration>> getPluginImplementation() {
|
||||
return ResourceCheckerPlugin.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return String.format("%s : %s - %s - %s - %s - %s",
|
||||
this.getClass().getSimpleName(),
|
||||
getName(), getVersion(), getDescription(),
|
||||
getSupportedCapabilities(),
|
||||
getPluginImplementation().getClass().getSimpleName());
|
||||
}
|
||||
|
||||
}
|
|
@ -25,7 +25,7 @@ import org.apache.http.util.EntityUtils;
|
|||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.informationsystem.resource_checker.ResourceCheckerPluginDeclaration;
|
||||
import org.gcube.informationsystem.resource_checker.ResourceCheckerPlugin;
|
||||
import org.gcube.informationsystem.resource_checker.beans.BasicFunctionalityBean;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
|
@ -99,7 +99,7 @@ public class SendNotification extends PluginStateNotification {
|
|||
JSONObject obj = new JSONObject();
|
||||
obj.put("job_id", pluginStateEvolution.getUUID().toString());
|
||||
obj.put("recipient", recipient);
|
||||
obj.put("job_name", pluginStateEvolution.getPluginDeclaration().getName());
|
||||
obj.put("job_name", pluginStateEvolution.getPluginDefinition().getName());
|
||||
obj.put("service_name", SERVICE_NAME);
|
||||
obj.put("status", "FAILED");
|
||||
obj.put("status_message", "original status reported by " + SERVICE_NAME + " was " + pluginStateEvolution.getPluginState()
|
||||
|
@ -198,7 +198,7 @@ public class SendNotification extends PluginStateNotification {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Dear ");
|
||||
sb.append(role).append(",").append("\n");
|
||||
sb.append("this is the report of the last running of the " + ResourceCheckerPluginDeclaration.NAME.toUpperCase() + " (" + dataStr + ").\nThe following missing resources have been found:\n");
|
||||
sb.append("this is the report of the last running of the " + new ResourceCheckerPlugin().getName() + " (" + dataStr + ").\nThe following missing resources have been found:\n");
|
||||
|
||||
Iterator<Entry<String, List<BasicFunctionalityBean>>> iterator = missingResourcesPerContext.entrySet().iterator();
|
||||
|
||||
|
@ -226,7 +226,7 @@ public class SendNotification extends PluginStateNotification {
|
|||
}
|
||||
sb.append("\n\n");
|
||||
sb.append(otherFailures + "\n");
|
||||
sb.append("Best,\n" + ResourceCheckerPluginDeclaration.NAME);
|
||||
sb.append("Best,\n" + new ResourceCheckerPlugin().getName());
|
||||
|
||||
String message = sb.toString();
|
||||
logger.debug("Going to send this message \n" + message);
|
||||
|
|
|
@ -1 +1 @@
|
|||
org.gcube.informationsystem.resource_checker.ResourceCheckerPluginDeclaration
|
||||
org.gcube.informationsystem.resource_checker.ResourceCheckerPlugin
|
|
@ -25,7 +25,7 @@ public class TestResourceChecker extends ContextTest {
|
|||
|
||||
ContextTest.setContextByName("/gcube");
|
||||
|
||||
ResourceCheckerPlugin checker = new ResourceCheckerPlugin(null);
|
||||
ResourceCheckerPlugin checker = new ResourceCheckerPlugin();
|
||||
Map<String, Object> inputs = new HashMap<String, Object>();
|
||||
inputs.put(SendNotification.RECIPIENT_KEY, null);
|
||||
inputs.put(ResourceCheckerPlugin.ROLE_TO_NOTIFY, "Administrator");
|
||||
|
@ -37,7 +37,9 @@ public class TestResourceChecker extends ContextTest {
|
|||
public void launchRemotely() throws Exception{
|
||||
ContextTest.setContextByName("/d4science.research-infrastructures.eu");
|
||||
|
||||
SmartExecutorClient smartExecutor = SmartExecutorClientFactory.getClient(ResourceCheckerPluginDeclaration.NAME);
|
||||
String name = new ResourceCheckerPlugin().getName();
|
||||
|
||||
SmartExecutorClient smartExecutor = SmartExecutorClientFactory.getClient(name);
|
||||
Assert.assertNotNull(smartExecutor);
|
||||
|
||||
try {
|
||||
|
@ -46,7 +48,7 @@ public class TestResourceChecker extends ContextTest {
|
|||
inputs.put(SendNotification.RECIPIENT_KEY, null);
|
||||
inputs.put(ResourceCheckerPlugin.ROLE_TO_NOTIFY, "Administrator");
|
||||
|
||||
LaunchParameter launchParameter = new LaunchParameter(ResourceCheckerPluginDeclaration.NAME, inputs);
|
||||
LaunchParameter launchParameter = new LaunchParameter(name, inputs);
|
||||
|
||||
// Every day at 8:00
|
||||
CronExpression cronExpression = new CronExpression("0 0 8 1/1 * ? *");
|
||||
|
|
Loading…
Reference in New Issue