All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tinkerpop.rexster.gremlin.GremlinGarbageCollector Maven / Gradle / Ivy

package com.tinkerpop.rexster.gremlin;

import java.util.Collection;

/**
 * Remove Gremlin sessions that have been idle for too long.
 * 

* Credit to Neo Technology (http://neotechnology.com/) for most of the code related to the * Gremlin in Rexster. Specifically, this code was borrowed from * https://github.com/neo4j/webadmin and re-purposed for Rexster's needs. *

* Based on Webling garbage collector by Pavel A. Yaskevich then re-purposed by * Jacob Hansson */ public class GremlinGarbageCollector extends Thread { long updateInterval = 3000000; // 50 minutes long maxIdleInterval = 1790000; // 29 minutes public GremlinGarbageCollector() { setDaemon(true); start(); } @Override public void run() { while (true) { try { Thread.sleep(updateInterval); } catch (InterruptedException e) { } Collection sessionKeys = GremlinSessions.getSessionKeys(); for (String sessionKey : sessionKeys) { // Make sure session exists (otherwise // GremlinSessions.getSession() will create it) if (GremlinSessions.hasSessionKey(sessionKey)) { // If idle time is above our threshold if (GremlinSessions.findSessionByKey(sessionKey).getIdleTime() > maxIdleInterval) { // Throw the GremlinSession instance to the wolves GremlinSessions.destroySession(sessionKey); } } } } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy