use of com.evolveum.midpoint.task.api.ClusterExecutionOptions in project midpoint by Evolveum.
the class ClusterwideUserSessionManagerImpl method getLoggedInPrincipals.
@Override
@NotNull
public List<UserSessionManagementType> getLoggedInPrincipals(Task task, OperationResult result) {
List<UserSessionManagementType> loggedUsers = guiProfiledPrincipalManager.getLocalLoggedInPrincipals();
Map<String, UserSessionManagementType> usersMap = new HashMap<>();
// fix for mid-6328
loggedUsers.forEach(loggedUser -> {
UserSessionManagementType addedUser = usersMap.get(loggedUser.getFocus().getOid());
if (addedUser != null) {
addedUser.setActiveSessions(addedUser.getActiveSessions() + loggedUser.getActiveSessions());
addedUser.getNode().addAll(loggedUser.getNode());
} else {
usersMap.put(loggedUser.getFocus().getOid(), loggedUser);
}
});
// We try to invoke this call also on nodes that are in transition. We want to get
// information as complete as realistically possible.
clusterExecutionHelper.execute((client, node, result1) -> {
client.path(ClusterServiceConsts.EVENT_LIST_USER_SESSION);
Response response = client.get();
LOGGER.debug("Remote-node retrieval of user sessions finished on {} with status {}, {}", node.getNodeIdentifier(), response.getStatusInfo().getStatusCode(), response.getStatusInfo().getReasonPhrase());
if (response.hasEntity()) {
UserSessionManagementListType remoteSessionsWrapper = response.readEntity(UserSessionManagementListType.class);
List<UserSessionManagementType> remoteSessions = remoteSessionsWrapper.getSession();
for (UserSessionManagementType remoteSession : MiscUtil.emptyIfNull(remoteSessions)) {
UserSessionManagementType existingUser = usersMap.get(remoteSession.getFocus().getOid());
if (existingUser != null) {
existingUser.setActiveSessions(existingUser.getActiveSessions() + remoteSession.getActiveSessions());
existingUser.getNode().addAll(remoteSession.getNode());
} else {
usersMap.put(remoteSession.getFocus().getOid(), remoteSession);
}
}
}
response.close();
}, new ClusterExecutionOptions().tryNodesInTransition(), " list principals from remote nodes ", result);
return new ArrayList<>(usersMap.values());
}
use of com.evolveum.midpoint.task.api.ClusterExecutionOptions in project midpoint by Evolveum.
the class ClusterwideUserSessionManagerImpl method terminateSessions.
@Override
public void terminateSessions(TerminateSessionEvent terminateSessionEvent, Task task, OperationResult result) {
guiProfiledPrincipalManager.terminateLocalSessions(terminateSessionEvent);
// We try to invoke this call also on nodes that are in transition. It is quite important
// that terminate session is executed on as wide scale as realistically possible.
clusterExecutionHelper.execute((client, node, result1) -> {
client.path(ClusterServiceConsts.EVENT_TERMINATE_SESSION);
Response response = client.post(terminateSessionEvent.toEventType());
LOGGER.info("Remote-node user session termination finished on {} with status {}, {}", node.getNodeIdentifier(), response.getStatusInfo().getStatusCode(), response.getStatusInfo().getReasonPhrase());
response.close();
}, new ClusterExecutionOptions().tryNodesInTransition(), "session termination", result);
}
use of com.evolveum.midpoint.task.api.ClusterExecutionOptions in project midpoint by Evolveum.
the class RestConnector method startRemoteScheduler.
public void startRemoteScheduler(NodeType node, OperationResult result) throws SchemaException {
clusterExecutionHelper.execute(node, (client, actualNode, result1) -> {
client.path(TaskConstants.START_LOCAL_SCHEDULER_REST_PATH);
Response response = client.post(null);
Response.StatusType statusInfo = response.getStatusInfo();
LOGGER.debug("Starting remote scheduler on {} finished with status {}: {}", node.getNodeIdentifier(), statusInfo.getStatusCode(), statusInfo.getReasonPhrase());
if (statusInfo.getFamily() != Response.Status.Family.SUCCESSFUL) {
LOGGER.warn("Starting scheduler on {} finished with status {}: {}", node.getNodeIdentifier(), statusInfo.getStatusCode(), statusInfo.getReasonPhrase());
result1.recordFatalError("Starting remote scheduler finished with status " + statusInfo.getStatusCode() + ": " + statusInfo.getReasonPhrase());
}
response.close();
}, new ClusterExecutionOptions().tryAllNodes(), "start scheduler", result);
}
use of com.evolveum.midpoint.task.api.ClusterExecutionOptions in project midpoint by Evolveum.
the class RestConnector method stopRemoteTaskRun.
public void stopRemoteTaskRun(String oid, NodeType node, OperationResult result) throws SchemaException {
clusterExecutionHelper.execute(node, (client, actualNode, result1) -> {
client.path(TaskConstants.STOP_LOCAL_TASK_REST_PATH_PREFIX + oid + TaskConstants.STOP_LOCAL_TASK_REST_PATH_SUFFIX);
Response response = client.post(null);
Response.StatusType statusInfo = response.getStatusInfo();
LOGGER.debug("Stopping task {} on {} finished with status {}: {}", oid, node.getNodeIdentifier(), statusInfo.getStatusCode(), statusInfo.getReasonPhrase());
if (statusInfo.getFamily() != Response.Status.Family.SUCCESSFUL) {
LOGGER.warn("Stopping task {} on {} finished with status {}: {}", oid, node.getNodeIdentifier(), statusInfo.getStatusCode(), statusInfo.getReasonPhrase());
result1.recordFatalError("Stopping remote task finished with status " + statusInfo.getStatusCode() + ": " + statusInfo.getReasonPhrase());
}
response.close();
}, new ClusterExecutionOptions().tryAllNodes(), "stop task", result);
}
use of com.evolveum.midpoint.task.api.ClusterExecutionOptions in project midpoint by Evolveum.
the class RestConnector method stopRemoteScheduler.
public void stopRemoteScheduler(NodeType node, OperationResult result) throws SchemaException {
clusterExecutionHelper.execute(node, (client, actualNode, result1) -> {
client.path(TaskConstants.STOP_LOCAL_SCHEDULER_REST_PATH);
Response response = client.post(null);
Response.StatusType statusInfo = response.getStatusInfo();
LOGGER.debug("Stopping remote scheduler on {} finished with status {}: {}", node.getNodeIdentifier(), statusInfo.getStatusCode(), statusInfo.getReasonPhrase());
if (statusInfo.getFamily() != Response.Status.Family.SUCCESSFUL) {
LOGGER.warn("Stopping scheduler on {} finished with status {}: {}", node.getNodeIdentifier(), statusInfo.getStatusCode(), statusInfo.getReasonPhrase());
result1.recordFatalError("Stopping remote scheduler finished with status " + statusInfo.getStatusCode() + ": " + statusInfo.getReasonPhrase());
}
response.close();
}, new ClusterExecutionOptions().tryAllNodes(), "stop scheduler", result);
}
Aggregations