Search in sources :

Example 1 with UserHistory

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());
    }
}
Also used : RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) UserHistory(org.ow2.proactive.resourcemanager.core.history.UserHistory) ArrayList(java.util.ArrayList) Client(org.ow2.proactive.resourcemanager.authentication.Client) LinkedList(java.util.LinkedList)

Example 2 with UserHistory

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;
}
Also used : UserHistory(org.ow2.proactive.resourcemanager.core.history.UserHistory) IOException(java.io.IOException) ActiveObjectCreationException(org.objectweb.proactive.ActiveObjectCreationException)

Aggregations

UserHistory (org.ow2.proactive.resourcemanager.core.history.UserHistory)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 ActiveObjectCreationException (org.objectweb.proactive.ActiveObjectCreationException)1 Client (org.ow2.proactive.resourcemanager.authentication.Client)1 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)1