use of org.ow2.proactive.resourcemanager.core.history.UserHistory in project scheduling by ow2-proactive.
the class RMCore method disconnect.
/**
* Disconnects the client and releases all nodes held by him
*/
public void disconnect(UniqueID clientId) {
Client client = RMCore.clients.remove(clientId);
if (client != null) {
List<RMNode> nodesToRelease = new LinkedList<>();
// expensive but relatively rare operation
for (RMNode rmnode : new ArrayList<>(allNodes.values())) {
// the same connection
if (client.equals(rmnode.getOwner()) && clientId.equals(rmnode.getOwner().getId())) {
if (rmnode.isToRemove()) {
removeNodeFromCoreAndSource(rmnode, client);
} else if (rmnode.isBusy()) {
nodesToRelease.add(rmnode);
}
}
}
// Force the nodes cleaning here to avoid the situation
// when the disconnected client still uses nodes.
// In the future we may clean nodes for any release request
nodesCleaner.cleanAndRelease(nodesToRelease);
// update the connection info in the DB
if (client.getHistory() != null) {
UserHistory userHistory = client.getHistory();
userHistory.setEndTime(System.currentTimeMillis());
dbManager.updateUserHistory(userHistory);
}
logger.info(client + " disconnected from " + client.getId().shortString());
} else {
logger.warn("Trying to disconnect unknown client with id " + clientId.shortString());
}
}
use of org.ow2.proactive.resourcemanager.core.history.UserHistory in project scheduling by ow2-proactive.
the class RMAuthenticationImpl method login.
/**
* Performs user authentication
*/
public ResourceManager login(Credentials cred) throws LoginException {
Client client = new Client(authenticate(cred), true);
client.setCredentials(cred);
if (RMCore.clients.containsKey(client.getId())) {
logger.info(client + " reconnected.");
}
RMCore.clients.put(client.getId(), client);
UserHistory history = new UserHistory(client);
RMDBManager.getInstance().saveUserHistory(history);
client.setHistory(history);
logger.info(client + " connected from " + client.getId().shortString());
try {
// return the stub on ResourceManager interface to keep avoid using server class on client side
return PAActiveObject.lookupActive(ResourceManager.class, PAActiveObject.getUrl(rmcore));
} catch (ActiveObjectCreationException e) {
rethrowStubException(e);
} catch (IOException e) {
rethrowStubException(e);
}
return null;
}
Aggregations