use of org.ow2.proactive.scheduler.common.exception.NotConnectedException in project scheduling by ow2-proactive.
the class RMRest method getRMThreadDump.
@Override
public String getRMThreadDump(String sessionId) throws NotConnectedException {
RMProxyUserInterface rm = checkAccess(sessionId);
String threadDump;
try {
threadDump = orThrowRpe(rm.getRMThreadDump().getStringValue());
} catch (Exception exception) {
return exception.getMessage();
}
return threadDump;
}
use of org.ow2.proactive.scheduler.common.exception.NotConnectedException in project scheduling by ow2-proactive.
the class RMRest method editNodeSource.
@Override
public NSState editNodeSource(String sessionId, String nodeSourceName, String infrastructureType, String[] infrastructureParameters, String[] infrastructureFileParameters, String policyType, String[] policyParameters, String[] policyFileParameters, String nodesRecoverable) throws NotConnectedException {
ResourceManager rm = checkAccess(sessionId);
NSState nsState = new NSState();
Object[] infraParams = this.getAllInfrastructureParameters(infrastructureType, infrastructureParameters, infrastructureFileParameters, rm);
Object[] policyParams = this.getAllPolicyParameters(policyType, policyParameters, policyFileParameters, rm);
try {
nsState.setResult(rm.editNodeSource(nodeSourceName, infrastructureType, infraParams, policyType, policyParams, Boolean.parseBoolean(nodesRecoverable)).getBooleanValue());
} catch (RuntimeException ex) {
nsState.setResult(false);
nsState.setErrorMessage(cleanDisplayedErrorMessage(ex.getMessage()));
nsState.setStackTrace(StringEscapeUtils.escapeJson(getStackTrace(ex)));
}
return nsState;
}
use of org.ow2.proactive.scheduler.common.exception.NotConnectedException in project scheduling by ow2-proactive.
the class RMRest method getNodesHistory.
@Override
public Map<String, Map<String, Map<String, List<RMNodeHistory>>>> getNodesHistory(String sessionId, long windowStart, long windowEnd) throws NotConnectedException {
ResourceManager rm = checkAccess(sessionId);
List<RMNodeHistory> rawDataFromRM = rm.getNodesHistory(windowStart, windowEnd);
// grouped by node source name, host name, and node name
Map<String, Map<String, Map<String, List<RMNodeHistory>>>> grouped = rawDataFromRM.stream().collect(Collectors.groupingBy(RMNodeHistory::getNodeSource, Collectors.groupingBy(RMNodeHistory::getHost, Collectors.groupingBy(this::getNodeName))));
grouped.values().forEach(a -> a.values().forEach(b -> {
b.values().forEach(c -> {
// sorting by startTime
c.sort(Comparator.comparing(RMNodeHistory::getStartTime));
c.forEach(nh -> {
// if startTime before window
if (nh.getStartTime() < windowStart) {
nh.setStartTime(windowStart);
}
// if endTime after window
if (windowEnd < nh.getEndTime()) {
nh.setEndTime(windowEnd);
}
if (nh.getEndTime() == 0) {
nh.setEndTime(windowEnd);
}
});
});
}));
return grouped;
}
use of org.ow2.proactive.scheduler.common.exception.NotConnectedException in project scheduling by ow2-proactive.
the class RMRest method acquireNodes.
@Override
public Set<String> acquireNodes(String sessionId, String sourceName, int numberNodes, boolean synchronous, long timeout, String nodeConfigJson) throws NotConnectedException, RestException {
if (numberNodes <= 0) {
throw new IllegalArgumentException("Invalid number of nodes: " + numberNodes);
}
ResourceManager rm = checkAccess(sessionId);
if (sourceName == null) {
throw new IllegalArgumentException("Node source name should not be null.");
}
Optional<RMNodeSourceEvent> nodeSource = rm.getExistingNodeSourcesList().stream().filter(ns -> sourceName.equals(ns.getSourceName())).findAny();
if (!nodeSource.isPresent()) {
throw new IllegalArgumentException(String.format("Specified node source [%s] not exist.", sourceName));
}
if (!NODE_SOURCE_DEPLOYED_STATUS.equals(nodeSource.get().getNodeSourceStatus())) {
throw new IllegalArgumentException(String.format("Specified node source [%s] is not deployed.", sourceName));
}
ObjectMapper mapper = new ObjectMapper();
Map<String, Object> nodeConfig;
try {
nodeConfig = mapper.readValue(nodeConfigJson, new TypeReference<Map<String, ?>>() {
});
} catch (Exception e) {
throw new IllegalArgumentException("Error during parsing the node configuration: " + nodeConfigJson, e);
}
if (synchronous) {
String acquireRequestId = "tmp:" + UUID.randomUUID().toString();
setRequestIdInNodeConfig(nodeConfig, acquireRequestId);
rm.acquireNodes(sourceName, numberNodes, timeout * 1000, nodeConfig);
waitUntil(timeout, "Nodes are not deployed within the specified timeout.", () -> rm.getNodesByTag(acquireRequestId).size() == numberNodes);
return orThrowRpe(rm.getNodesByTag(acquireRequestId));
} else {
rm.acquireNodes(sourceName, numberNodes, timeout * 1000, nodeConfig);
return new HashSet<>();
}
}
use of org.ow2.proactive.scheduler.common.exception.NotConnectedException in project scheduling by ow2-proactive.
the class RMRest method rmDisconnect.
@Override
public void rmDisconnect(String sessionId) throws NotConnectedException {
RMProxyUserInterface rm = checkAccess(sessionId);
PAFuture.getFutureValue(rm.disconnect(), RMListenerProxy.MONITORING_INTERFACE_TIMEOUT);
sessionStore.terminate(sessionId);
}
Aggregations