Skip to content

Commit

Permalink
Merge pull request #440 from eclipse-arrowhead/development
Browse files Browse the repository at this point in the history
Release v4.6.2
  • Loading branch information
borditamas authored Mar 19, 2024
2 parents c6185d4 + 1443efa commit d85e04f
Show file tree
Hide file tree
Showing 21 changed files with 192 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public void publishAuthUpdate(final long updatedConsumerSystemId) {
private void initializeSystemRequestDTO() {
logger.debug("initializeSystemRequestDTO started...");

systemRequestDTO = new SystemRequestDTO();
systemRequestDTO.setAddress(address);
systemRequestDTO.setPort(port);
systemRequestDTO.setSystemName(systemName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import org.apache.http.HttpStatus;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -49,6 +50,7 @@
import eu.arrowhead.common.Defaults;
import eu.arrowhead.common.Utilities;
import eu.arrowhead.common.core.CoreSystem;
import eu.arrowhead.common.database.entity.ChoreographerPlan;
import eu.arrowhead.common.database.entity.ChoreographerSession;
import eu.arrowhead.common.database.entity.Logs;
import eu.arrowhead.common.database.service.CommonDBService;
Expand All @@ -58,6 +60,7 @@
import eu.arrowhead.common.dto.shared.ChoreographerPlanListResponseDTO;
import eu.arrowhead.common.dto.shared.ChoreographerPlanRequestDTO;
import eu.arrowhead.common.dto.shared.ChoreographerPlanResponseDTO;
import eu.arrowhead.common.dto.shared.ChoreographerRunPlanRequestByClientDTO;
import eu.arrowhead.common.dto.shared.ChoreographerRunPlanRequestDTO;
import eu.arrowhead.common.dto.shared.ChoreographerRunPlanResponseDTO;
import eu.arrowhead.common.dto.shared.ChoreographerSessionStatus;
Expand Down Expand Up @@ -111,7 +114,8 @@ public class ChoreographerPlanController {
private static final String DELETE_PLAN_HTTP_400_MESSAGE = "Could not remove Plan.";

private static final String START_SESSION_HTTP_200_MESSAGE = "Initiated plan execution with given id(s).";
private static final String START_PLAN_HTTP_400_MESSAGE = "Could not start plan with given id(s).";
private static final String START_SESSION_BY_CLIENT_HTTP_200_MESSAGE = "Initiated plan execution with given id(s) or name(s).";
private static final String START_PLAN_HTTP_400_MESSAGE = "Could not start plan.";

private static final String ABORT_SESSION_HTTP_200_MESSAGE = "Initiated session abortion with given id.";
private static final String ABORT_SESSION_HTTP_400_MESSAGE = "Could not abort session with given id.";
Expand Down Expand Up @@ -367,6 +371,69 @@ public void abortSession(@PathVariable final Long id) {

return new ChoreographerCheckPlanResponseDTO(id, result.getErrorMessages(), result.getNeedInterCloud());
}

//-------------------------------------------------------------------------------------------------
@ApiOperation(value = "Initiate the start of one or more plans.", tags = { CoreCommonConstants.SWAGGER_TAG_CLIENT })
@ApiResponses(value = {
@ApiResponse(code = HttpStatus.SC_OK, message = START_SESSION_BY_CLIENT_HTTP_200_MESSAGE, responseContainer = "List", response = ChoreographerRunPlanResponseDTO.class),
@ApiResponse(code = HttpStatus.SC_BAD_REQUEST, message = START_PLAN_HTTP_400_MESSAGE, response= ErrorMessageDTO.class),
@ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = CoreCommonConstants.SWAGGER_HTTP_401_MESSAGE, response= ErrorMessageDTO.class),
@ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = CoreCommonConstants.SWAGGER_HTTP_500_MESSAGE, response= ErrorMessageDTO.class)
})
@PostMapping(path = CommonConstants.OP_CHOREOGRAPHER_CLIENT_SERVICE_SESSION_START_URI, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody public List<ChoreographerRunPlanResponseDTO> startPlansByClient(@RequestBody final List<ChoreographerRunPlanRequestByClientDTO> requests) {
logger.debug("startPlans started...");

if (requests == null || requests.isEmpty()) {
throw new BadPayloadException("No plan specified to start.", HttpStatus.SC_BAD_REQUEST, CommonConstants.CHOREOGRAPHER_URI + CommonConstants.OP_CHOREOGRAPHER_CLIENT_SERVICE_SESSION_START_URI);
}

final List<ChoreographerRunPlanResponseDTO> results = new ArrayList<>(requests.size());
for (final ChoreographerRunPlanRequestByClientDTO request : requests) {
request.setAllowInterCloud(gatekeeperIsPresent && request.isAllowInterCloud()); // change inter-cloud flag based on gatekeeper presence in the cloud
if (request.getPlanId() == null) {
request.setPlanId(findPlan(request.getName())); // try to find plan id by name
}

final ChoreographerRunPlanResponseDTO response = planChecker.checkPlanForExecution(request);

if (!Utilities.isEmpty(response.getErrorMessages())) {
results.add(response);
} else {
final ChoreographerSession session = sessionDBService.initiateSession(request.getPlanId(), request.getQuantity(), createNotifyUri(request));
results.add(new ChoreographerRunPlanResponseDTO(request.getPlanId(), session.getId(), session.getQuantityGoal(), response.getNeedInterCloud()));

logger.debug("Sending a message to {}.", ChoreographerService.START_SESSION_DESTINATION);
jms.convertAndSend(ChoreographerService.START_SESSION_DESTINATION, new ChoreographerStartSessionDTO(session.getId(), request.getPlanId(), request.isAllowInterCloud(), request.getChooseOptimalExecutor()));
}
}

return results;
}

//-------------------------------------------------------------------------------------------------
@ApiOperation(value = "Initiate the abortion of the specified session.", response = Void.class, tags = { CoreCommonConstants.SWAGGER_TAG_CLIENT })
@ApiResponses (value = {
@ApiResponse(code = HttpStatus.SC_OK, message = ABORT_SESSION_HTTP_200_MESSAGE),
@ApiResponse(code = HttpStatus.SC_BAD_REQUEST, message = ABORT_SESSION_HTTP_400_MESSAGE),
@ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = CoreCommonConstants.SWAGGER_HTTP_401_MESSAGE),
@ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = CoreCommonConstants.SWAGGER_HTTP_500_MESSAGE)
})
@DeleteMapping(path = CommonConstants.OP_CHOREOGRAPHER_CLIENT_SERVICE_SESSION_ABORT_URI)
public void abortSessionByClient(@PathVariable final Long id) {
logger.debug("New abort session request received with id: {}.", id);

if (id < 1) {
throw new BadPayloadException(ID_NOT_VALID_ERROR_MESSAGE, HttpStatus.SC_BAD_REQUEST, CommonConstants.CHOREOGRAPHER_URI + CommonConstants.OP_CHOREOGRAPHER_CLIENT_SERVICE_SESSION_ABORT_URI);
}

final ChoreographerSession session = sessionDBService.getSessionById(id);
if (session.getStatus() == ChoreographerSessionStatus.DONE) {
throw new BadPayloadException("Session with id " + id + " couldn't be aborted due to its DONE status");
}

choreographerService.abortSession(id, null, MANUAL_ABORT_MESSAGE);
}

//=================================================================================================
// assistant methods
Expand All @@ -376,4 +443,15 @@ private String createNotifyUri(final ChoreographerRunPlanRequestDTO request) {
return Utilities.isEmpty(request.getNotifyAddress()) ? null
: request.getNotifyProtocol() + "://" + request.getNotifyAddress() + ":" + request.getNotifyPort() + "/" + request.getNotifyPath();
}

//-------------------------------------------------------------------------------------------------
private Long findPlan(final String name) {
if (Utilities.isEmpty(name)) {
return null;
}

final Optional<ChoreographerPlan> plan = planDBService.getPlanByName(name);

return plan.isPresent() ? plan.get().getId() : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ public ChoreographerPlan getPlanById(final long id) {
throw new ArrowheadException(CoreCommonConstants.DATABASE_OPERATION_EXCEPTION_MSG, ex);
}
}

//-------------------------------------------------------------------------------------------------
public Optional<ChoreographerPlan> getPlanByName(final String name) {
logger.debug("getPlanByName started...");

return choreographerPlanRepository.findByName(name);
}

//-------------------------------------------------------------------------------------------------
public ChoreographerPlanResponseDTO getPlanByIdResponse(final long id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,29 @@ public class ConfigurationController {

return ret;
}

//-------------------------------------------------------------------------------------------------
@ApiOperation(value = "Interface to get an other application's configuration", response = ConfigurationResponseDTO.class, tags = { CoreCommonConstants.SWAGGER_TAG_CLIENT })
@ApiResponses (value = {
@ApiResponse(code = HttpStatus.SC_OK, message = CoreCommonConstants.SWAGGER_HTTP_200_MESSAGE),
@ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = CoreCommonConstants.SWAGGER_HTTP_401_MESSAGE),
@ApiResponse(code = HttpStatus.SC_NOT_FOUND, message = CoreCommonConstants.SWAGGER_HTTP_404_MESSAGE),
@ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = CoreCommonConstants.SWAGGER_HTTP_500_MESSAGE)
})
@GetMapping(path= CommonConstants.OP_CONFIGURATION_CONF_BY_PROXY + "/{systemName}", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody public ConfigurationResponseDTO confGetByProxy(@PathVariable(value="systemName", required = true) String systemName) {
if (Utilities.isEmpty(systemName)) {
throw new InvalidParameterException(OP_NOT_VALID_ERROR_MESSAGE, HttpStatus.SC_BAD_REQUEST, CommonConstants.OP_CONFIGURATION_CONF_BY_PROXY);
}
systemName = systemName.toLowerCase().trim();

final ConfigurationResponseDTO ret = configurationDBService.getConfigForSystem(systemName);
if (ret == null) {
throw new DataNotFoundException(NOT_FOUND_ERROR_MESSAGE, HttpStatus.SC_NOT_FOUND, CommonConstants.OP_CONFIGURATION_CONF_BY_PROXY + "/" + systemName);
}

return ret;
}

//-------------------------------------------------------------------------------------------------
@ApiOperation(value = "Interface to list all configuration files", response = ConfigurationListResponseDTO.class, tags = { CoreCommonConstants.SWAGGER_TAG_MGMT })
Expand Down Expand Up @@ -238,6 +261,25 @@ public class ConfigurationController {

return configResponse;
}

//-------------------------------------------------------------------------------------------------
@ApiOperation(value = "Stores/updates an other application's configuration", response = ConfigurationResponseDTO.class, tags = { CoreCommonConstants.SWAGGER_TAG_CLIENT })
@ApiResponses(value = {
@ApiResponse(code = HttpStatus.SC_OK, message = PUT_CONFIG_MGMT_HTTP_200_MESSAGE),
@ApiResponse(code = HttpStatus.SC_BAD_REQUEST, message = PUT_CONFIG_MGMT_HTTP_400_MESSAGE),
@ApiResponse(code = HttpStatus.SC_UNAUTHORIZED, message = CoreCommonConstants.SWAGGER_HTTP_401_MESSAGE),
@ApiResponse(code = HttpStatus.SC_INTERNAL_SERVER_ERROR, message = CoreCommonConstants.SWAGGER_HTTP_500_MESSAGE)
})
@PutMapping(path = CommonConstants.OP_CONFIGURATION_SAVE_CONF_BY_PROXY, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody public ConfigurationResponseDTO storeConfigurationForSystemByProxy(@RequestBody final ConfigurationRequestDTO config) {
logger.debug("New storeConfigurationForSystemByProxy put request received.");
final String origin = CommonConstants.CONFIGURATION_URI + CommonConstants.OP_CONFIGURATION_SAVE_CONF_BY_PROXY;

validateConfigRequestDTO(config.getSystemName(), config, origin);
final ConfigurationResponseDTO configResponse = configurationDBService.setConfigForSystem(config.getSystemName(), config);

return configResponse;
}

//-------------------------------------------------------------------------------------------------
@ApiOperation(value = "Delete configuration", response = ConfigurationResponseDTO.class, tags = { CoreCommonConstants.SWAGGER_TAG_MGMT })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,14 @@ public class CommonConstants {

public static final String CORE_SERVICE_CONFIGURATION_CONF = "conf";
public static final String CORE_SERVICE_CONFIGURATION_RAWCONF = "confraw";
public static final String CORE_SERVICE_CONFIGURATION_CONF_BY_PROXY = "conf-by-proxy";
public static final String CORE_SERVICE_CONFIGURATION_SAVE_CONF_BY_PROXY = "save-conf-by-proxy";

public static final String CORE_SERVICE_CHOREOGRAPHER_PROCESS = "choreographer-service";
public static final String CORE_SERVICE_CHOREOGRAPHER_REGISTER_EXECUTOR = "executor-register";
public static final String CORE_SERVICE_CHOREOGRAPHER_UNREGISTER_EXECUTOR = "executor-unregister";
public static final String CORE_SERVICE_CHOREOGRAPHER_START_SESSION = "choreographer-start-session";
public static final String CORE_SERVICE_CHOREOGRAPHER_ABORT_SESSION = "choreographer-abort-session";

public static final String CORE_SERVICE_CERTIFICATEAUTHORITY_SIGN = "ca-sign";
public static final String CORE_SERVICE_CERTIFICATEAUTHORITY_LIST_CERTIFICATES = "ca-list-certificates";
Expand All @@ -109,7 +113,7 @@ public class CommonConstants {
public static final String CORE_SERVICE_QOSMONITOR_INTRA_PING_MEDIAN_MEASUREMENT = "qos-monitor-intra-ping-median-measurement";
public static final String CORE_SERVICE_QOSMONITOR_INTER_DIRECT_PING_MEASUREMENT = "qos-monitor-inter-direct-ping-measurement";
public static final String CORE_SERVICE_QOSMONITOR_INTER_RELAY_ECHO_MEASUREMENT = "qos-monitor-inter-relay-echo-measurement";
public static final String CORE_SERVICE_QOSMONITOR_PUBLIC_KEY = "qos-monitor-public-key";
public static final String CORE_SERVICE_QOSMONITOR_PUBLIC_KEY = "qos-monitor-public-key";
public static final String CORE_SERVICE_QOSMONITOR_JOIN_RELAY_TEST = "qos-monitor-join-relay-test";
public static final String CORE_SERVICE_QOSMONITOR_INIT_RELAY_TEST = "qos-monitor-init-relay-test";
public static final String CORE_SERVICE_SERVICEREGISTRY_REGISTER = "service-register";
Expand Down Expand Up @@ -280,6 +284,8 @@ public class CommonConstants {
public static final String OP_CONFIGURATION_CONF = "/config";
public static final String OP_CONFIGURATION_RAWCONF = "/config/raw";
public static final String OP_CONFIGURATION_MGMT_MANAGE = "/mgmt/config";
public static final String OP_CONFIGURATION_CONF_BY_PROXY = "/proxy/config";
public static final String OP_CONFIGURATION_SAVE_CONF_BY_PROXY = "/proxy/save-config";

public static final String CHOREOGRAPHER_URI = "/choreographer";
public static final String CHOREOGRAPHER_SESSION_MGMT_URI = CoreCommonConstants.MGMT_URI + "/session";
Expand All @@ -294,6 +300,8 @@ public class CommonConstants {
public static final String OP_CHOREOGRAPHER_EXECUTOR_UNREGISTER = "/executor/unregister";
public static final String OP_CHOREOGRAPHER_NOTIFY_STEP_DONE = "/executor/notify-step-done";
public static final String OP_CHOREOGRAPHER_EXECUTOR_UNREGISTER_REQUEST_PARAM_NAME = "name";
public static final String OP_CHOREOGRAPHER_CLIENT_SERVICE_SESSION_START_URI = "/session/start";
public static final String OP_CHOREOGRAPHER_CLIENT_SERVICE_SESSION_ABORT_URI = "/session/abort/{id}";

public static final String GATEWAY_URI = "/gateway";
public static final String OP_GATEWAY_KEY_URI = "/publickey";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,14 @@ public enum CoreSystem {

CHOREOGRAPHER(Defaults.DEFAULT_CHOREOGRAPHER_PORT, List.of(CoreSystemService.CHOREOGRAPHER_SERVICE,
CoreSystemService.CHOREOGRAPHER_REGISTER_EXECUTOR_SERVICE,
CoreSystemService.CHOREOGRAPHER_UNREGISTER_EXECUTOR_SERVICE)),
CoreSystemService.CHOREOGRAPHER_UNREGISTER_EXECUTOR_SERVICE,
CoreSystemService.CHOREOGRAPHER_START_SESSION_SERVICE,
CoreSystemService.CHOREOGRAPHER_ABORT_SESSION_SERVICE)),

CONFIGURATION(Defaults.DEFAULT_CONFIGURATION_PORT, List.of(CoreSystemService.CONFIGURATION_SERVICE,
CoreSystemService.CONFIGURATION_RAW_SERVICE)),
CoreSystemService.CONFIGURATION_RAW_SERVICE,
CoreSystemService.CONFIGURATION_BY_PROXY_SERVICE,
CoreSystemService.CONFIGURATION_SAVE_BY_PROXY_SERVICE)),

QOSMONITOR(Defaults.DEFAULT_QOSMONITOR_PORT, List.of(CoreSystemService.QOSMONITOR_INTRA_PING_MEASUREMENT_SERVICE,
CoreSystemService.QOSMONITOR_INTRA_PING_MEDIAN_MEASUREMENT_SERVICE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,15 @@ public enum CoreSystemService {
CONFIGURATION_SERVICE(CommonConstants.CORE_SERVICE_CONFIGURATION_CONF, CommonConstants.CONFIGURATION_URI + CommonConstants.OP_CONFIGURATION_CONF),
CONFIGURATION_RAW_SERVICE(CommonConstants.CORE_SERVICE_CONFIGURATION_RAWCONF, CommonConstants.CONFIGURATION_URI + CommonConstants.OP_CONFIGURATION_RAWCONF, List.of(new InterfaceData(CommonConstants.HTTP, CommonConstants.BINARY))),
CONFIGURATION_MANAGE_SERVICE(CommonConstants.CORE_SERVICE_CONFIGURATION_CONF, CommonConstants.CONFIGURATION_URI + CommonConstants.OP_CONFIGURATION_MGMT_MANAGE),
CONFIGURATION_BY_PROXY_SERVICE(CommonConstants.CORE_SERVICE_CONFIGURATION_CONF_BY_PROXY, CommonConstants.CONFIGURATION_URI + CommonConstants.OP_CONFIGURATION_CONF_BY_PROXY),
CONFIGURATION_SAVE_BY_PROXY_SERVICE(CommonConstants.CORE_SERVICE_CONFIGURATION_SAVE_CONF_BY_PROXY, CommonConstants.CONFIGURATION_URI + CommonConstants.OP_CONFIGURATION_SAVE_CONF_BY_PROXY),

// Choreographer services
CHOREOGRAPHER_SERVICE(CommonConstants.CORE_SERVICE_CHOREOGRAPHER_PROCESS, CommonConstants.CHOREOGRAPHER_URI + CommonConstants.OP_CHOREOGRAPHER_NOTIFY_STEP_DONE),
CHOREOGRAPHER_REGISTER_EXECUTOR_SERVICE(CommonConstants.CORE_SERVICE_CHOREOGRAPHER_REGISTER_EXECUTOR, CommonConstants.CHOREOGRAPHER_URI + CommonConstants.OP_CHOREOGRAPHER_EXECUTOR_REGISTER),
CHOREOGRAPHER_UNREGISTER_EXECUTOR_SERVICE(CommonConstants.CORE_SERVICE_CHOREOGRAPHER_UNREGISTER_EXECUTOR, CommonConstants.CHOREOGRAPHER_URI + CommonConstants.OP_CHOREOGRAPHER_EXECUTOR_UNREGISTER),
CHOREOGRAPHER_START_SESSION_SERVICE(CommonConstants.CORE_SERVICE_CHOREOGRAPHER_START_SESSION, CommonConstants.CHOREOGRAPHER_URI + CommonConstants.OP_CHOREOGRAPHER_CLIENT_SERVICE_SESSION_START_URI),
CHOREOGRAPHER_ABORT_SESSION_SERVICE(CommonConstants.CORE_SERVICE_CHOREOGRAPHER_ABORT_SESSION, CommonConstants.CHOREOGRAPHER_URI + CommonConstants.OP_CHOREOGRAPHER_CLIENT_SERVICE_SESSION_ABORT_URI),

// QoS Monitor services

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package eu.arrowhead.common.dto.shared;

import java.io.Serializable;

public class ChoreographerRunPlanRequestByClientDTO extends ChoreographerRunPlanRequestDTO implements Serializable {

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

private static final long serialVersionUID = -7679624305702873335L;

private String name;

//-------------------------------------------------------------------------------------------------
public String getName() { return name; }

//-------------------------------------------------------------------------------------------------
public void setName(final String name) { this.name = name; }
}
2 changes: 1 addition & 1 deletion docker/Dockerfile-system
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN cd /opt/arrowhead-build && \

FROM eclipse-temurin:11.0.19_7-jre

ENV AH_VERSION=4.6.1
ENV AH_VERSION=4.6.2

COPY --from=build /opt/arrowhead /opt/arrowhead
COPY --from=build /opt/arrowhead-temp /opt/arrowhead-temp
Expand Down
2 changes: 1 addition & 1 deletion gams/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.4.0</version>
<version>2.9.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.gbenroscience/parser-ng -->
<dependency>
Expand Down
Loading

0 comments on commit d85e04f

Please sign in to comment.