Search in sources :

Example 1 with Sleeper

use of org.objectweb.proactive.utils.Sleeper in project scheduling by ow2-proactive.

the class SessionsCleaner method run.

public void run() {
    while (!stop) {
        logger.info("cleaning session started, " + sessionStore.size() + " existing session(s) ");
        int removedSession = sessionStore.terminateExpiredSessions(TIMEOUT_DELAY);
        // clean every 5 minutes
        logger.info("cleaning session ended, " + removedSession + " session(s) removed");
        new Sleeper(CLEAN_PERIOD, logger).sleep();
    }
    logger.info(Thread.currentThread().getName() + " terminated");
}
Also used : Sleeper(org.objectweb.proactive.utils.Sleeper)

Example 2 with Sleeper

use of org.objectweb.proactive.utils.Sleeper in project scheduling by ow2-proactive.

the class RMStateCaching method init_.

private static void init_() {
    while (rm == null) {
        String url = PortalConfiguration.RM_URL.getValueAsString();
        String cred_path = PortalConfiguration.RM_CACHE_CREDENTIALS.getValueAsStringOrNull();
        try {
            if (rm == null) {
                rm = PAActiveObject.newActive(RMProxyUserInterface.class, new Object[] {});
                if (cred_path != null && !(new File(cred_path)).exists()) {
                    logger.error("Credentials path set in " + PortalConfiguration.RM_CACHE_CREDENTIALS.getKey() + " but file " + cred_path + " does not exist");
                }
                if (cred_path != null && new File(cred_path).exists()) {
                    Credentials cred = Credentials.getCredentials(cred_path);
                    rm.init(url, cred);
                } else {
                    String login = PortalConfiguration.RM_CACHE_LOGIN.getValueAsString();
                    String password = PortalConfiguration.RM_CACHE_PASSWORD.getValueAsString();
                    rm.init(url, new CredData(login, password));
                }
            }
        } catch (Exception e) {
            logger.warn("Could not connect to resource manager at " + url + " retrying in 8 seconds", e);
            if (rm != null) {
                PAActiveObject.terminateActiveObject(rm, true);
                rm = null;
            }
            new Sleeper(8 * 1000, logger).sleep();
            continue;
        }
    }
}
Also used : RMProxyUserInterface(org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface) CredData(org.ow2.proactive.authentication.crypto.CredData) PAActiveObject(org.objectweb.proactive.api.PAActiveObject) Sleeper(org.objectweb.proactive.utils.Sleeper) File(java.io.File) Credentials(org.ow2.proactive.authentication.crypto.Credentials)

Aggregations

Sleeper (org.objectweb.proactive.utils.Sleeper)2 File (java.io.File)1 PAActiveObject (org.objectweb.proactive.api.PAActiveObject)1 CredData (org.ow2.proactive.authentication.crypto.CredData)1 Credentials (org.ow2.proactive.authentication.crypto.Credentials)1 RMProxyUserInterface (org.ow2.proactive.resourcemanager.common.util.RMProxyUserInterface)1