Skip to content

Commit

Permalink
Updated to Xenon 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bpmweel committed Nov 2, 2017
1 parent 541b903 commit 422b132
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 59 deletions.
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ plugins {
id 'org.springframework.boot' version '1.5.6.RELEASE'
}

springBoot {
mainClass = 'nl.esciencecenter.computeservice.rest.Swagger2SpringBoot'
}

bootRepackage {
mainClass = 'nl.esciencecenter.computeservice.rest.Swagger2SpringBoot'
}
Expand All @@ -24,8 +28,7 @@ repositories {
// In this section you declare the dependencies for your production and test code
dependencies {
// Xenon
compile "com.github.NLeSC:Xenon:master-SNAPSHOT"
//compile group: 'nl.esciencecenter.xenon', name: 'xenon', version: '2.0.0'
compile group: 'nl.esciencecenter.xenon', name: 'xenon', version: '2.1.0'

//Spring(boot)
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.6.RELEASE'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class ComputeResource {
@JsonProperty("scheduler")
private AdaptorConfig schedulerConfig;
@JsonProperty("filesystem")
@JsonProperty(value="filesystem", required=false)
private AdaptorConfig filesystemConfig;

@JsonProperty(value="cwlCommand", required=false)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
package nl.esciencecenter.computeservice.rest;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;

import org.apache.catalina.servlets.WebdavServlet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -15,18 +9,13 @@
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

import springfox.documentation.swagger2.annotations.EnableSwagger2;

Expand All @@ -40,27 +29,6 @@
"nl.esciencecenter.computeservice.cwl.*" })
public class Swagger2SpringBoot implements CommandLineRunner, ApplicationListener<EmbeddedServletContainerInitializedEvent> {
private static final Logger logger = LoggerFactory.getLogger(Swagger2SpringBoot.class);

// I can't get the CORS for the embedded webdav to work, so it's not much sense
// to include it.
// @Bean
// public static ServletRegistrationBean servletRegistrationBean() {
//
// final ServletRegistrationBean registration = new ServletRegistrationBean(new WebdavServlet());
//
// final Map<String, String> params = new HashMap<String, String>();
// params.put("debug", "1");
// params.put("listings", "true");
// params.put("readonly", "false");
//
// params.put("cors.allowed.origins", "*");
//
// registration.setInitParameters(params);
// registration.addUrlMappings("/webdav/*");
// registration.setLoadOnStartup(1);
//
// return registration;
// }

@Value("${server.address}")
String bindAdress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import nl.esciencecenter.computeservice.rest.model.JobState;
import nl.esciencecenter.computeservice.rest.model.StatePreconditionException;
import nl.esciencecenter.computeservice.rest.model.WorkflowBinding;
import nl.esciencecenter.xenon.XenonException;
import nl.esciencecenter.xenon.filesystems.Path;

@Service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ private void initialize() throws XenonException, IOException {
// TODO: Is assertions the nicest way?
assert(resource != null);
assert(resource.getSchedulerConfig() != null);
assert(resource.getFilesystemConfig() != null);


// Start up submitted jobs
Expand Down Expand Up @@ -170,18 +169,51 @@ public JobService getJobService() {
public void setJobService(JobService jobService) {
this.jobService = jobService;
}

public Scheduler getScheduler() throws XenonException {
if (scheduler == null) {
// Initialize xenon scheduler
ComputeResource resource = getConfig().defaultComputeResource();
AdaptorConfig schedulerConfig = resource.getSchedulerConfig();


private void checkSchedulerStates() throws XenonException {
ComputeResource resource = getConfig().defaultComputeResource();
AdaptorConfig schedulerConfig = resource.getSchedulerConfig();
AdaptorConfig fileSystemConfig = resource.getFilesystemConfig();

boolean useSchedulerFilesystem = fileSystemConfig == null;
boolean recreateScheduler = false;
boolean recreateFileSystem = false;
if(useSchedulerFilesystem) {
if (scheduler == null || !scheduler.isOpen() || remoteFileSystem == null || !remoteFileSystem.isOpen()) {
recreateScheduler = true;
recreateFileSystem = true;
}

} else {
if (scheduler == null || !scheduler.isOpen()) {
recreateScheduler = true;
}
if (remoteFileSystem == null || !remoteFileSystem.isOpen()) {
recreateFileSystem = true;
}
}
if (recreateScheduler) {
logger.debug("Creating a scheduler to run jobs...");
scheduler = Scheduler.create(schedulerConfig.getAdaptor(), schedulerConfig.getLocation(),
schedulerConfig.getCredential(), schedulerConfig.getProperties());
schedulerConfig.getCredential(), schedulerConfig.getProperties());
}
if (recreateFileSystem) {
if (useSchedulerFilesystem && Scheduler.getAdaptorDescription(scheduler.getAdaptorName()).usesFileSystem()) {
logger.debug("Using scheduler filesystem as a remote filesystem...");
remoteFileSystem = scheduler.getFileSystem();
} else {
// Initialize remote filesystem
logger.debug("Creating remote filesystem...");
remoteFileSystem = FileSystem.create(fileSystemConfig.getAdaptor(), fileSystemConfig.getLocation(),
fileSystemConfig.getCredential(), fileSystemConfig.getProperties());

logger.debug("Remote working directory: " + remoteFileSystem.getWorkingDirectory());
}
}
}

public Scheduler getScheduler() throws XenonException {
checkSchedulerStates();
return scheduler;
}

Expand All @@ -197,16 +229,7 @@ public void setScheduler(Scheduler scheduler) {
}

public FileSystem getRemoteFileSystem() throws XenonException {
if (remoteFileSystem == null || !remoteFileSystem.isOpen()) {
// Initialize remote filesystem
logger.debug("Creating remote filesystem...");
ComputeResource resource = getConfig().defaultComputeResource();
AdaptorConfig fileSystemConfig = resource.getFilesystemConfig();
remoteFileSystem = FileSystem.create(fileSystemConfig.getAdaptor(), fileSystemConfig.getLocation(),
fileSystemConfig.getCredential(), fileSystemConfig.getProperties());

logger.debug("Remote working directory: " + remoteFileSystem.getWorkingDirectory());
}
checkSchedulerStates();
return remoteFileSystem;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import nl.esciencecenter.computeservice.rest.service.staging.StringToFileStagingObject;
import nl.esciencecenter.computeservice.rest.service.staging.XenonStager;
import nl.esciencecenter.xenon.XenonException;
import nl.esciencecenter.xenon.filesystems.FileSystem;
import nl.esciencecenter.xenon.filesystems.Path;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import nl.esciencecenter.computeservice.rest.model.Job;
import nl.esciencecenter.computeservice.rest.model.JobRepository;
import nl.esciencecenter.computeservice.rest.service.JobService;
import nl.esciencecenter.computeservice.rest.service.XenonService;
import nl.esciencecenter.xenon.XenonException;
import nl.esciencecenter.xenon.filesystems.FileSystem;
Expand All @@ -17,13 +16,11 @@ public class DeleteJobTask implements Runnable {
private String jobId;
private XenonService service;
private JobRepository repository;
private JobService jobService;

public DeleteJobTask(String jobId, XenonService service) throws XenonException {
this.jobId = jobId;
this.service = service;
this.repository = service.getRepository();
this.jobService = service.getJobService();
}

@Override
Expand Down

0 comments on commit 422b132

Please sign in to comment.