Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ wrapper
/application-skeleton-consumer/target
/application-skeleton-publisher/target
/application-skeleton-subscriber/target
/application-skeleton-executor/target
/mvnw
/mvnw.cmd
/.settings
Expand Down
38 changes: 38 additions & 0 deletions application-skeleton-executor/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions application-skeleton-executor/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>arrowhead-application-skeleton-executor</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
54 changes: 54 additions & 0 deletions application-skeleton-executor/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>eu.arrowhead</groupId>
<artifactId>application-skeleton-java-spring</artifactId>
<version>4.4.0.0</version>
</parent>

<artifactId>arrowhead-application-skeleton-executor</artifactId>
<name>Arrowhead Executor Skeleton</name>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>application.properties</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package eu.arrowhead.application.skeleton.executor;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import ai.aitia.arrowhead.application.library.ArrowheadService;
import ai.aitia.arrowhead.application.library.config.ApplicationInitListener;
import eu.arrowhead.application.skeleton.executor.execution.ExecutionManager;
import eu.arrowhead.common.core.CoreSystem;

@Component
public class ExecutorApplicationInitListener extends ApplicationInitListener {

//=================================================================================================
// members

@Autowired
private ArrowheadService arrowheadService;

@Autowired
private ExecutionManager executionManager;

private final Logger logger = LogManager.getLogger(ExecutorApplicationInitListener.class);

//=================================================================================================
// methods

//-------------------------------------------------------------------------------------------------
@Override
protected void customInit(final ContextRefreshedEvent event) {

//Checking the availability of necessary core systems
checkCoreSystemReachability(CoreSystem.CHOREOGRAPHER);

//Initialize Arrowhead Context
arrowheadService.updateCoreServiceURIs(CoreSystem.CHOREOGRAPHER);

//Start Executor Manager
executionManager.start();

//TODO: implement here any custom behavior on application start up
}

//-------------------------------------------------------------------------------------------------
@Override
public void customDestroy() {

//Stop Executor Manager
executionManager.interrupt();

//TODO: implement here any custom behavior on application shout down
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package eu.arrowhead.application.skeleton.executor;

public class ExecutorConstants {

//=================================================================================================
// members

public static final String THREAD_NUM_EXECUTION_WORKER = "thread.num.execution-worker";
public static final String $THREAD_NUM_EXECUTION_WORKER_WD = "${" + THREAD_NUM_EXECUTION_WORKER + ":1}";

//=================================================================================================
// assistant methods

//-------------------------------------------------------------------------------------------------
private ExecutorConstants() {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package eu.arrowhead.application.skeleton.executor;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

import eu.arrowhead.common.CommonConstants;

@SpringBootApplication
@ComponentScan(basePackages = {CommonConstants.BASE_PACKAGE}) //TODO: add custom packages if any
public class ExecutorMain {

//=================================================================================================
// methods

//-------------------------------------------------------------------------------------------------
public static void main(final String[] args) {
SpringApplication.run(ExecutorMain.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package eu.arrowhead.application.skeleton.executor.configuration;

public class ConfigConstants {

//=================================================================================================
// members

public static final int MIN_MAXKEEPALIVE_REQUESTS = 1;
public static final int MAX_MAXKEEPALIVE_REQUESTS = 1000;

//=================================================================================================
// assistant methods

//-------------------------------------------------------------------------------------------------
private ConfigConstants() {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package eu.arrowhead.application.skeleton.executor.configuration;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.validation.annotation.Validated;

@Configuration
@PropertySource("classpath:application.properties")
@ConfigurationProperties(prefix = "container")
@Validated
public class ContainerConfProperties {

//=================================================================================================
// members

@Min(ConfigConstants.MIN_MAXKEEPALIVE_REQUESTS)
@Max(ConfigConstants.MAX_MAXKEEPALIVE_REQUESTS)
private int maxKeepAliveRequests;

//=================================================================================================
// methods

//-------------------------------------------------------------------------------------------------

public int getMaxKeepAliveRequests() { return maxKeepAliveRequests; }
public void setMaxKeepAliveRequests(final int maxKeepAliveRequests) { this.maxKeepAliveRequests = maxKeepAliveRequests; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package eu.arrowhead.application.skeleton.executor.configuration;

import org.apache.coyote.http11.AbstractHttp11Protocol;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ContainerConfiguration implements WebServerFactoryCustomizer<TomcatServletWebServerFactory> {

//=================================================================================================
// members

@Autowired
ContainerConfProperties containerConfProperties;

private final Logger log = LogManager.getLogger( ContainerConfiguration.class);

//=================================================================================================
// methods

//-------------------------------------------------------------------------------------------------
@SuppressWarnings("rawtypes")
@Override
public void customize(TomcatServletWebServerFactory factory) {
factory.addConnectorCustomizers(connector -> {
final AbstractHttp11Protocol protocol = (AbstractHttp11Protocol) connector.getProtocolHandler();

protocol.setMaxKeepAliveRequests(containerConfProperties.getMaxKeepAliveRequests());

log.info("####################################################################################");
log.info("#");
log.info("# TomcatCustomizer");
log.info("#");
log.info("# custom maxKeepAliveRequests {}", protocol.getMaxKeepAliveRequests());
log.info("# origin keepalive timeout: {} ms", protocol.getKeepAliveTimeout());
log.info("# keepalive timeout: {} ms", protocol.getKeepAliveTimeout());
log.info("# connection timeout: {} ms", protocol.getConnectionTimeout());
log.info("# max connections: {}", protocol.getMaxConnections());
log.info("#");
log.info("####################################################################################");
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package eu.arrowhead.application.skeleton.executor.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import eu.arrowhead.application.skeleton.executor.service.ExecutorService;
import eu.arrowhead.common.CommonConstants;
import eu.arrowhead.common.dto.shared.ChoreographerAbortStepRequestDTO;
import eu.arrowhead.common.dto.shared.ChoreographerExecuteStepRequestDTO;
import eu.arrowhead.common.dto.shared.ChoreographerExecutorServiceInfoRequestDTO;
import eu.arrowhead.common.dto.shared.ChoreographerExecutorServiceInfoResponseDTO;

@RestController
//@RequestMapping("/executor") // TODO: specify the base URI here
public class ExecutorController {

//=================================================================================================
// members

@Autowired
private ExecutorService executorService;

//TODO: add your variables here

//=================================================================================================
// methods

//-------------------------------------------------------------------------------------------------
@GetMapping(path = CommonConstants.ECHO_URI)
public String echo() {
return "Got it!";
}

//-------------------------------------------------------------------------------------------------
@PostMapping(path = CommonConstants.CHOREOGRAPHER_EXECUTOR_CLIENT_SERVICE_START_URI, consumes = MediaType.APPLICATION_JSON_VALUE)
public void start(@RequestBody final ChoreographerExecuteStepRequestDTO request) {
executorService.startExecution(request);
}

//-------------------------------------------------------------------------------------------------
@PostMapping(path = CommonConstants.CHOREOGRAPHER_EXECUTOR_CLIENT_SERVICE_ABORT_URI, consumes = MediaType.APPLICATION_JSON_VALUE)
public void abort(@RequestBody final ChoreographerAbortStepRequestDTO request) {
executorService.abortExecution(request);
}

//-------------------------------------------------------------------------------------------------
@PostMapping(path = CommonConstants.CHOREOGRAPHER_EXECUTOR_CLIENT_SERVICE_INFO_URI, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody public ChoreographerExecutorServiceInfoResponseDTO serviceInfo(@RequestBody final ChoreographerExecutorServiceInfoRequestDTO request) {
return executorService.collectServiceInfo(request);
}

//-------------------------------------------------------------------------------------------------
//TODO: implement here your executor related REST end points
}
Loading