Fixing bugs

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/vre-management/smart-executor@142186 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2017-02-03 15:29:25 +00:00
parent 195e62e474
commit 4cedf6c46b
6 changed files with 37 additions and 30 deletions

View File

@ -118,7 +118,7 @@
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-graphdb</artifactId>
<artifactId>orientdb-client</artifactId>
</dependency>
<dependency>

View File

@ -35,8 +35,6 @@ import org.slf4j.LoggerFactory;
*/
public class RunnablePlugin<T extends Plugin<? extends PluginDeclaration>> implements Runnable {
private static final String LOCALHOST = "localhost";
/**
* Logger
*/
@ -94,15 +92,10 @@ public class RunnablePlugin<T extends Plugin<? extends PluginDeclaration>> imple
taskUsageRecord.setConsumerId(SmartExecutorInitializator.getClientInfo().getId());
try{
RunOn runOn = ScheduledTask.generateRunOn();
Ref hnRef = runOn.getHostingNode();
taskUsageRecord.setRefHostingNodeId(hnRef.getId());
taskUsageRecord.setHost(hnRef.getAddress());
}catch(Exception e){
taskUsageRecord.setRefHostingNodeId(LOCALHOST);
taskUsageRecord.setHost(LOCALHOST);
}
RunOn runOn = ScheduledTask.generateRunOn();
Ref hnRef = runOn.getHostingNode();
taskUsageRecord.setRefHostingNodeId(hnRef.getId());
taskUsageRecord.setHost(hnRef.getAddress());
if(inputs!=null && inputs.size()>0){
HashMap<String, Serializable> map =

View File

@ -85,26 +85,40 @@ public class ScheduledTask {
return runOn;
}
private static final String LOCALHOST = "localhost";
/**
* @param runOn the runOn to set
*/
public static RunOn generateRunOn() {
HostingNode hostingNode = ContextProvider.get().profile(HostingNode.class);
Ref hostingNodeRef = new Ref(hostingNode.id(), hostingNode.profile().description().name());
GCoreEndpoint gCoreEndpoint = ContextProvider.get().profile(GCoreEndpoint.class);
String address = "";
Group<Endpoint> endpoints = gCoreEndpoint.profile().endpoints();
for(Endpoint endpoint : endpoints){
if(endpoint.name().contains(Constants.remote_management)){
continue;
}else{
address = endpoint.uri().toString();
break;
}
Ref hostingNodeRef = null;
try {
HostingNode hostingNode = ContextProvider.get().profile(HostingNode.class);
hostingNodeRef = new Ref(hostingNode.id(), hostingNode.profile().description().name());
}catch (Exception e) {
//
hostingNodeRef = new Ref(LOCALHOST, LOCALHOST);
}
Ref eServiceRef = new Ref(gCoreEndpoint.id(), address);
Ref eServiceRef = null;
try {
GCoreEndpoint gCoreEndpoint = ContextProvider.get().profile(GCoreEndpoint.class);
String address = "";
Group<Endpoint> endpoints = gCoreEndpoint.profile().endpoints();
for(Endpoint endpoint : endpoints){
if(endpoint.name().contains(Constants.remote_management)){
continue;
}else{
address = endpoint.uri().toString();
break;
}
}
eServiceRef = new Ref(gCoreEndpoint.id(), address);
}catch (Exception e) {
eServiceRef = new Ref(LOCALHOST, LOCALHOST);
}
RunOn runOn = new RunOn(hostingNodeRef, eServiceRef);

View File

@ -11,7 +11,7 @@ import org.gcube.vremanagement.executor.persistence.SmartExecutorPersistenceFact
*/
public class ScheduledTaskPersistenceFactory {
public static ScheduledTaskPersistence getLaunchConfiguration() throws Exception {
public static ScheduledTaskPersistence getScheduledTaskPersistence() throws Exception {
return (ScheduledTaskPersistence) SmartExecutorPersistenceFactory.getPersistenceConnector();
}

View File

@ -149,7 +149,7 @@ public class SmartExecutorScheduler {
}
try {
ScheduledTaskPersistence stc = ScheduledTaskPersistenceFactory.getLaunchConfiguration();
ScheduledTaskPersistence stc = ScheduledTaskPersistenceFactory.getScheduledTaskPersistence();
ScheduledTask scheduledTask = new ScheduledTask(uuid, parameter);
logger.debug("Going to persist Scheduled Task {} : {} ",
scheduledTask);
@ -286,7 +286,7 @@ public class SmartExecutorScheduler {
protected void removeFromPersistence(boolean global, UUID uuid, boolean remove) throws SchedulePersistenceException{
try {
ScheduledTaskPersistence stc = ScheduledTaskPersistenceFactory.getLaunchConfiguration();
ScheduledTaskPersistence stc = ScheduledTaskPersistenceFactory.getScheduledTaskPersistence();
if(remove){
logger.debug("Going to remove the SmartExecutor Scheduled Task {} from global scheduling", uuid);
stc.removeScheduledTask(uuid);

View File

@ -69,7 +69,7 @@ public class SmartExecutorPersistenceConnectorTest extends ScopedTest {
@Test
public void getAvailableScheduledTasksTest() throws Exception {
ScheduledTaskPersistence stc = ScheduledTaskPersistenceFactory.getLaunchConfiguration();
ScheduledTaskPersistence stc = ScheduledTaskPersistenceFactory.getScheduledTaskPersistence();
Assert.assertNotNull(stc);
Assert.assertEquals(OrientDBPersistenceConnector.class, stc.getClass());