Clean up message body generation, update gradle

Change-Id: Ifca9186dc2258826ca001e37ca0aa9d286e995a5
This commit is contained in:
Rudi Schlatte 2024-02-12 12:40:59 +01:00
parent a23692efa0
commit d0ee713142
4 changed files with 18 additions and 10 deletions

Binary file not shown.

View File

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

View File

@ -114,8 +114,8 @@ public class ExnConnector {
* Connect to ActiveMQ and activate all publishers and consumers. It is
* an error to start the controller more than once.
*
* @param synchronizer if non-null, a countdown latch that will be signaled
* when the connector is stopped by calling {@link
* @param synchronizer if non-null, a countdown latch that will be
* signaled when the connector is stopped by calling {@link
* CountDownLatch#countDown} once.
*/
public synchronized void start(CountDownLatch synchronizer) {

View File

@ -26,15 +26,23 @@ public class SalConnector {
private static final ObjectMapper mapper = new ObjectMapper();
/**
* Get list of node candidates that fulfil the requirements.
*
* See https://github.com/ow2-proactive/scheduling-abstraction-layer/blob/master/documentation/nodecandidates-endpoints.md#71--filter-node-candidates-endpoint
*
* @param requirements The list of requirements.
* @param appID The application ID, if available.
* @return A list of node candidates, or null in case of error.
*/
public static List<NodeCandidate> findNodeCandidates(List<Requirement> requirements, String appID) {
Map<String, Object> msg = new HashMap<>();
Map<String, Object> metadata = new HashMap<>();
metadata.put("user", "admin");
msg.put("metaData", metadata);
Map<String, Object> msg;
try {
msg.put("body", mapper.writeValueAsString(requirements));
msg = Map.of(
"metaData", Map.of("user", "admin"),
"body", mapper.writeValueAsString(requirements));
} catch (JsonProcessingException e) {
log.error("Could not convert requirements list to JSON string", e);
log.error("Could not convert requirements list to JSON string (this should never happen)", e);
return null;
}
Map<String, Object> response = ExnConnector.findNodeCandidates.sendSync(msg, appID, null, false);
@ -42,7 +50,7 @@ public class SalConnector {
try {
return Arrays.asList(mapper.readValue(body, NodeCandidate[].class));
} catch (JsonProcessingException e) {
log.error("Error receiving findNodeCandidates result", e);
log.error("Error receiving findNodeCandidates result (this should never happen)", e);
return null;
}
}